A method and device for data set segmentation and restoration

By using IPLD nodes and Merkle tree technology in the process of segmenting and restoring large data sets, the problem of fragment size gap and directory structure is solved, efficient segmentation and restoration of the data set is achieved, and the consistency of fragment sizes and The directory hierarchy is complete.

CN114253933BActive Publication Date: 2024-09-27SHANGHAI NUOWA LINGKE TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111581784.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-22
Publication Date
2024-09-27
Estimated Expiration
2041-12-22

AI Technical Summary

Technical Problem

In the process of segmenting and restoring large data sets, existing technologies have problems such as large differences in fragment size, difficulty in extracting some files, and inability to retain the original directory hierarchical structure.

Method used

Obtain file information by traversing the file directory where large data sets are stored, construct IPLD nodes and Merkel trees based on set comparison conditions, generate root identification information of the slice sub-root graph, and search and search based on the file sharding path during restoration. Restore the files to ensure that the fragment sizes are consistent and the directory structure is intact.

Benefits of technology

The size of the shards after splitting a large data set is basically the same, the original directory hierarchy is retained, and files in the shards can be quickly extracted and browsed, and files in the shards can be used without downloading the complete files.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114253933B
    Figure CN114253933B
Patent Text Reader

Abstract

The purpose of this application is to provide a method and device for data set segmentation and restoration. This application stores the information of each file in the traversed file directory storing a large data set into a file list; obtains the information of the current file to be processed from the file list, and determines the file path to add to the target file in the subgraph according to the set comparison conditions and the information of the current file to be processed; converts the target file into an IPLD node, and uses the IPLD node to build a Merkle tree relative to the file directory according to the file path of the target file on each node, and generates the root identification information of the slice sub-root graph. Download the root identification information of all slice sub-root graphs; search for the remaining file segments under the same file according to the file path of the found file segment, and restore them to one file according to the order. In this way, the size of the sliced ​​segments can be basically consistent, the original directory layer structure is retained, and the complete files in the downloaded segments can be used directly.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computers, and in particular to a method and device for segmenting and restoring a data set. Background Art

[0002] With the development of society, the data generated by people is becoming more and more massive, and there is an urgent need for a method to segment, store and restore large data sets. IPFS (InterPlanetary File System) builds a peer-to-peer distributed file system, realizing truly decentralized storage.

[0003] If you import the entire large data set (TB, PB level) into IPFS and generate a root identification information (CID), although the steps are simple, you will encounter many problems, such as the import time is too long and it may fail. If you need to extract a part of the file, you have to download the entire data set. In this case, you need to split the large data set. There are several existing splitting schemes:

[0004] 1) Add to IPFS in batches by directory;

[0005] 2) Use tools to compress the entire data set into a compressed package of a specified size, and then add it to IPFS;

[0006] 3) Directories that do not exceed a certain threshold are directly added to IPFS, and directories that exceed the threshold are compressed into a compressed package of a specified size and then added to IPFS.

[0007] The existing solutions have the following problems:

[0008] 1) Although the first solution above divides the large data set, it cannot control the size of the directory well. The size of the divided fragments may vary greatly, which is not conducive to extracting some files from the large fragments;

[0009] 2) Although the second solution can well control the size of each shard, it also requires all files to be downloaded and decompressed when extracting files. The content and directory hierarchy of a single shard cannot be seen at all, which is not conducive to file extraction;

[0010] 3) The third solution is a combination of the first two solutions, which solves the problem to a certain extent. However, if you want to extract the files in the compressed package, you still need to collect all the compressed packages before decompressing them, and it also destroys the original directory hierarchy structure. Summary of the invention

[0011] One purpose of the present application is to provide a method and device for data set segmentation and restoration, which can solve a series of problems in the prior art such as large size differences in the shards after segmentation of large data sets, difficulty in extracting some files, and inability to retain the original directory hierarchy structure.

[0012] According to one aspect of the present application, a method for segmenting a data set is provided, the method comprising:

[0013] Traverse the file directory storing the large data set, and store the information of each file obtained through the traversal into a file list, wherein the information of each file includes the file path, file name and file size;

[0014] Acquire information of the current file to be processed from the file list, and determine the file path to be added to the target file in the subgraph according to the set comparison condition and the information of the current file to be processed;

[0015] The target file is converted into an IPLD node, and a Merkle tree is constructed relative to the file directory according to the file path of the target file on each node using the IPLD node to generate root identification information of the slice sub-root graph.

[0016] Optionally, determining the file path to be added to the target file in the subgraph according to the set comparison condition and the information of the current file to be processed includes:

[0017] Compare the total size of the file set in the subgraph and the size of the current file to be processed with the specified slicing threshold;

[0018] Determine the target file whose file path is added to the subgraph based on the comparison result.

[0019] Optionally, determining the file path to add to the target file in the subgraph according to the comparison result includes:

[0020] If the total size of the file set in the subgraph plus the size of the current file to be processed is less than the specified slicing threshold, the current file to be processed is used as the target file, and the file path of the current file to be processed is added to the subgraph, and the file to be processed is continued to be obtained from the file list;

[0021] If the total size of the file collection in the subgraph plus the size of the current file to be processed is greater than the specified slicing threshold, the current file to be processed is segmented according to the specified slicing threshold to obtain file segments, and the start and end offsets of the file segments are recorded. The remaining file parts after the current file to be processed are placed in the file list, and the updated file list is traversed until the target file is obtained.

[0022] Optionally, the method comprises:

[0023] When traversing the file list, if there is no file to be processed, the file or file fragment in the subgraph is directly switched to an IPLD node.

[0024] Optionally, converting the target file into an IPLD node includes:

[0025] Traverse the target files in the subgraph, open the target files, and pass the file contents of the target files to the slicer module in the form of byte streams;

[0026] In the splitter module, a Splitter is constructed according to the received file byte stream;

[0027] Pass the constructed Splitter to the DAG construction module;

[0028] Generate a DAG object of IPLD nodes through the DAG construction module and return the root node of IPLD.

[0029] Optionally, using the IPLD node to construct a Merkle tree relative to the file directory according to the file path of the target file on each node, comprising:

[0030] Create a root directory node of the Merkle tree, and put the root directory node into a data structure diagram of an IPLD node for storing the Merkle tree;

[0031] Traverse each IPLD node in the subgraph. If there is an unprocessed node, parse the relative path of the target file on the unprocessed node and obtain the last-level directory as the value of the node in the data structure graph. If it is empty, use the root as the value.

[0032] Searching in the data structure diagram whether a directory node of the file path already exists, if so, adding the file node and the directory node to the link of the directory node, if not, creating an empty directory node, adding the file node and the directory node to the link of the created directory node;

[0033] The DAG construction module is called to store the nodes in the data structure diagram into the data storage module in the form of protocol buffer serialization, and the root identification information of the root node is returned.

[0034] Optionally, the method comprises:

[0035] Calculate the number of output slices according to the slice size of the large data set, and determine the number of subgraphs according to the number of slices;

[0036] The progress of file segmentation in the large data set is determined according to the number of the subgraphs and the root identification information of the generated slice sub-root graph.

[0037] According to another aspect of the present application, a method for restoring a data set is also provided, the method comprising:

[0038] Download the root identification information of all slice sub-root graphs from the system that supports the IPLD data structure;

[0039] Traversing the file directory storing the large data set, if there are unprocessed files, determining whether the unprocessed files are file fragments;

[0040] If yes, take out a file fragment from the unprocessed file, and search for the remaining file fragments under the same file in the root identification information of all the slice sub-root graphs according to the file path of the taken out file fragment, wherein the file path includes the specified suffix;

[0041] Restore all fragment files under the same file into one file in sequence.

[0042] Optionally, download the root identification information of all slice sub-root graphs from a system that supports the IPLD data structure, including:

[0043] Construct a DAG path for file shards relative to the root identification information of each large data set shard in a system that supports the IPLD data structure;

[0044] Download the root identification information of all slice sub-root graphs according to the DAG path.

[0045] According to another aspect of the present application, a device for segmenting a data set is also provided, the device comprising:

[0046] one or more processors; and

[0047] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the method as described above.

[0048] According to another aspect of the present application, a device for restoring a data set is also provided, the device comprising:

[0049] one or more processors; and

[0050] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the method as described above.

[0051] According to another aspect of the present application, a computer-readable medium is provided, on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the method described above.

[0052] Compared with the prior art, the present application traverses the file directory storing the large data set, and stores the information of each file obtained by the traversal into a file list, wherein the information of each file includes the file path, file name and file size information; obtains the information of the current file to be processed from the file list, and determines the file path to be added to the target file in the subgraph according to the set comparison conditions and the information of the current file to be processed; converts the target file into an IPLD node, and uses the IPLD node to build a Merkle tree relative to the file directory according to the file path of the target file on each node, and generates the root identification information of the slice sub-root graph. When restoring, the root identification information of all slice sub-root graphs is downloaded from the system supporting the IPLD data structure; the remaining file fragments under the same file are searched in the root identification information of all slice sub-root graphs according to the file path of the found file fragment, wherein the file path includes the specified suffix; and all the fragment files under the same file are restored to one file according to the order. In this way, the fragment sizes of the large data set after being segmented can be basically consistent, and the original directory layer structure is also retained, and the complete files in the downloaded fragments can be directly used. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:

[0054] Figure 1 A schematic diagram of a method for segmenting a data set provided according to one aspect of the present application is shown;

[0055] Figure 2 A schematic diagram of the process of segmenting a large data set in one embodiment of the present application is shown;

[0056] Figure 3 A schematic diagram showing a process of converting a file into an IPLD node in an embodiment of the present application is shown;

[0057] Figure 4 A schematic diagram of a process for constructing a Merkle tree according to a relative directory in one embodiment of the present application is shown;

[0058] Figure 5 A flowchart showing a method for restoring a data set according to another aspect of the present application is shown.

[0059] Figure 6 A schematic diagram of the process of restoring files in a data set in one embodiment of the present application is shown.

[0060] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION

[0061] The present application is described in further detail below in conjunction with the accompanying drawings.

[0062] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (eg, a central processing unit (CPU)), an input / output interface, a network interface and a memory.

[0063] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0064] Computer readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, Phase-Change RAM (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of random access memory (RAM), Read-Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. According to the definition in this article, computer-readable media does not include non-transitory media such as modulated data signals and carrier waves.

[0065] Figure 1A flow chart of a method for data set segmentation provided according to one aspect of the present application is shown, the method comprising: steps S11 to S13, wherein, in step S11, the file directory storing the large data set is traversed, and the information of each file obtained by the traversal is stored in a file list, wherein the information of each file includes information of the file path, file name and file size; in step S12, the information of the current file to be processed is obtained from the file list, and the target file whose file path is added to the subgraph is determined according to the set comparison conditions and the information of the current file to be processed; in step S13, the target file is converted into an IPLD node, and a Merkle tree is constructed relative to the file directory according to the file path of the target file on each node using the IPLD node, and the root identification information of the slice sub-root graph is generated. Thus, the size of the shards after the large data set is segmented can be basically consistent, and the original directory layer structure is retained, and the original directory layer structure can be restored during restoration, and the complete files in the downloaded shards can be directly used.

[0066] Specifically, in step S11, the file directory storing the large data set is traversed, and the information of each file obtained by the traversal is stored in a file list, wherein the information of each file includes information of the file path, file name and file size; here, the large data set, such as a data set reaching the TB or PB level, is relatively large and needs to be segmented. The large data set includes many files, and the file directory of the large data set is traversed to obtain the information of each file contained in the large data set according to the file directory, including the file path, file name and file size, and the traversed file information is stored in the file list, so as to segment the large data set according to the processing situation of each file in the file list.

[0067] Specifically, in step S12, the information of the current file to be processed is obtained from the file list, and the file path is determined to be added to the target file in the subgraph according to the set comparison conditions and the information of the current file to be processed; here, the file list includes the information of each file, and the file list is traversed to check whether there are unprocessed files. If so, the information of the current file to be processed is taken out, so as to determine whether to segment the file to be processed according to the set comparison conditions of the file, and then determine the target file. The target file can be a file fragment or a whole file. When the size of the whole file does not exceed the set size, it indicates that it can be used directly without segmentation. A complete file is segmented into multiple files according to size requirements, and each generated file fragment has its own file path and file size; after determining the target file, the file path of the target file is added to the subgraph, and the subgraph stores a file collection, thereby converting it into a file collection before the directed acyclic graph (DAG) structure, so as to facilitate the subsequent construction of file fragments or file root identification information for the subgraph, thereby retaining the original directory hierarchy structure.

[0068] Specifically, in step S13, the target file is converted into an IPLD node, and the IPLD node is used to construct a Merkle tree relative to the file directory according to the file path of the target file on each node, and the root identification information of the slice sub-root graph is generated. Here, the target file obtained above is converted into an IPLD node, so that the Merkle tree is constructed using the IPLD node. During the construction, the Merkle tree is constructed according to the file path of the target file on each node relative to the file directory of the large data set, so as to retain the original directory hierarchy structure, and the root identification information (ContentIdentifier, CID) of the tree is obtained after the construction. The CID is the identification information of the slice sub-root graph, and the slice sub-root graph is the corresponding subgraph after the file is segmented, so as to obtain the CID corresponding to each file slice, and after the file is segmented, the corresponding CID is found according to the path of the target file to restore the file.

[0069] In one embodiment of the present application, the target file includes the original current file to be processed and the file fragments obtained after the current file to be processed is segmented, and the file path of the file fragment in the target file includes a specified suffix. Here, according to the actual situation, the target file can be an original file or a file fragment. If the current file to be processed does not meet the segmentation condition, the target file is the original file of the current file to be processed, and when it meets the segmentation condition and needs to be segmented, the target file is a file fragment. After segmentation, the specified suffix is ​​added to the path of the file fragment, so that all file fragments are searched using the suffix, wherein the specified suffix is ​​a special suffix, and the format of the special suffix is, for example: original file name-total-total number of fragments-part-fragment sequence number, for example, the ex.jpg file is segmented into two file fragments: ex.jpg-total-2-part-1 and ex.jpg-total-2-part-2.

[0070] In some embodiments of the present application, in step S12, the total size of the file set in the subgraph and the size of the current file to be processed are compared with the specified slice threshold; the file path is determined to be added to the target file in the subgraph based on the comparison result. Here, one subgraph corresponds to one file to be processed. When obtaining the current file to be processed, it is determined whether the total size of the file set of the corresponding subgraph plus the size of the current file to be processed is less than the specified slice threshold. For example, the slice size (that is, the specified slice threshold) set according to actual needs is 32GiB. When slicing, it is determined whether the file is segmented and how to segment it into file segments based on the slice size; thus, the target file is determined based on the comparison result, that is, whether it is a whole file or a file slice after the file is segmented, and the file path of the determined target file is added to the subgraph.

[0071] Specifically, if the total size of the file set in the subgraph plus the size of the current file to be processed is less than the specified slicing threshold, the current file to be processed is used as the target file, and the file path of the current file to be processed is added to the subgraph, and the files to be processed are continued to be obtained from the file list; if the total size of the file set in the subgraph plus the size of the current file to be processed is greater than the specified slicing threshold, the current file to be processed is segmented according to the specified slicing threshold to obtain file fragments, the start and end offsets of the file fragments are recorded, and the remaining file parts after the current file to be processed are placed in the file list, and the updated file list is traversed until the target file is obtained. Here, if the total size of the file set of the subgraph corresponding to the current file to be processed plus the size of the current file to be processed is less than the specified slicing threshold, it means that the current file to be processed does not need to be segmented, and the path of the current file to be processed can be directly added to the subgraph, so that after the Merkle tree is constructed using the subgraph, the subgraph is cleared of data, and other files in the file list that have not been processed are continued to be traversed, and the new subgraph corresponds to the newly obtained unprocessed files. When the total size of the file collection in the subgraph plus the size of the current file to be processed is greater than the specified slicing threshold, it means that the current file to be processed is large and does not meet the current file size requirement, and needs to be split. The splitting is performed according to the specified slicing threshold, so as to ensure that the subsequent split files are basically the same size as the current split files, and the start and end offsets of the obtained file slices are recorded, so as to add the path of the file slices cut out according to the remaining size of the subgraph to the subgraph, and the path of the file slices after being split according to the slicing threshold is added to the new subgraph (the new subgraph size space has been filled with the split file slices), and the remaining part of the file after the split is put into the file list. For example, if the current file to be processed is 52GiB, it is split. A 10GiB file slice is cut according to the remaining size of the subgraph, and a 32GiB file slice is cut according to the specified slice threshold. For the remaining 10GiB file portion, the path of the 10GiB file slice is added to the current subgraph, and the path corresponding to the 32GiB file slice is added to a new subgraph. The subgraph represents a complete file shard, and the remaining 10GiB file portion is put into the file list. If the size of the file after being cut according to the remaining size of the subgraph is less than the specified threshold, the remaining file portion is directly added to the file list, and the file list is continued to be traversed, and the above steps are repeated until the files are cut and all target files are obtained.

[0072] In some embodiments of the present application, the method includes: when traversing the file list, if there is no file to be processed, the file or file fragment in the subgraph is directly switched to an IPLD node. Here, when no file to be processed is checked in the file list, it indicates that all the files in the file list have been processed, then all the target files (files or file fragments) of the obtained subgraph are directly switched to IPLD nodes, and the path of the target file has been added to the subgraph, and then a Merkle tree is constructed using these nodes to generate the slice subgraph root CID.

[0073] In some embodiments of the present application, the method includes: calculating the number of output slices according to the slice size of the large data set, determining the number of subgraphs according to the number of slices; and determining the progress of file segmentation in the large data set according to the number of subgraphs and the root identification information of the generated slice sub-root graph. Here, before traversing the file list, the number of output slices can be calculated according to the slice size of the large data set, that is, the number of file slices that can be output can be calculated, so that the corresponding number of subgraphs can be determined, one file slice corresponds to one subgraph, and then the progress of the current file segmentation can be judged according to the generated CID and the number of subgraphs, for example, the current progress is that 1000 CIDs can be generated for the files in the large data set.

[0074] In a specific embodiment of the present application, when slicing, the slice size is a threshold value set according to actual needs, such as 32GiB, the file directory is the directory storing the large data set, and the sub-graph is the file collection in the slice, including files and file slices. Figure 2As shown, the following steps are included: Step 1, traverse the file directory, obtain the information of each file, including the path, file name and file size, and store them in the file list; Step 2, calculate the number of output slices according to the size of the large data set; Step 3, traverse the file list, check whether there are unprocessed files, if the judgment is true, go to step 4, otherwise go to step 9; Step 4, check whether the cumulative size of the subgraph (that is, the total size of the file set in the subgraph) plus the file size is less than the specified slice size, if the judgment is not, go to step 5, otherwise add the file path to the subgraph and go to step 3, if the cumulative size of the subgraph plus the file size is equal to the specified slice size, go to step 6, otherwise split the file and record the start and end offsets of the file, and then Add the file slices of the other part to the file list, wherein the file is firstly cut into file slices of the remaining size of the subgraph, and then the second half of the file is cut into file slices according to the slice size as the maximum size of the file slice, and the generated file slices are "the file slices of the other part"; step 6, convert the files or file slices in the subgraph into IPLD nodes; step 7, use these nodes to build a Merkle tree according to the relative directory, and generate the slice subgraph root CID; step 8, clear the subgraph data, and then go to step 3; step 9, convert the files or file slices in the subgraph into IPLD nodes; step 10, use these nodes to build a Merkle tree according to the relative directory, and generate the slice subgraph root CID; step 11, the cutting is completed.

[0075] It should be noted that the full name of IPLD is InterPlanetary Linked Data. It is a standard specification of a data structure used to build fully decentralized applications. It does not rely on IPFS, but IPLD is used in IPFS. The core of IPLD is MerkleDAG (Merkle Directed Acyclic Graph) based on the DAG structure. MerkleDAG consists of two types: nodes and links. They each have their own unique identifier CID (Content IDentifier). Nodes are used to store data, and links are used to store the CID values ​​of all subordinate nodes. Therefore, a piece of content or file must have only one unique root CID. If two CIDs are the same, their contents must be the same.

[0076] In some embodiments of the present application, when converting the target file into an IPLD node, the target files in the subgraph are traversed, the target file is opened, and the file content of the target file is passed to the splitter module in the form of a byte stream; a Splitter splitter is constructed in the splitter module according to the received file byte stream; the constructed Splitter splitter is passed to the DAG construction module; a DAG object of the IPLD node is generated through the DAG construction module, and the root node of the IPLD is returned. Here, if Figure 3 As shown in the figure, when a file is converted into an IPLD node, the files or file fragments in the subgraph are traversed, the file is opened, and the source file (i.e., the file content) is passed to the splitter module in the form of a byte stream; after the splitter module obtains the file byte stream, it builds a Splitter splitter according to the set file size (such as 1 MiB); the Splitter splitter is passed to the DAG construction module to build the MerkleDAG data format; the DAG construction module's Layout method is used to disassemble and form a DAG object that conforms to the IPLD specification. Specifically, the data is first divided into blocks, and the blocks are combined into a tree, which can also be called a DAG. The leaf nodes of the tree are data blocks, and each layer is set to 1024 nodes. The tree is filled from bottom to top, and the final tree root ID (Root CID) is the encrypted hash value of the source file, which is used to represent this resource.

[0077] In some embodiments of the present application, when the IPLD node is used to construct a Merkle tree based on the file path of the target file on each node relative to the file directory, a root directory node of the Merkle tree is created, and the root directory node is placed in the data structure diagram of the IPLD node used to store the Merkle tree; each IPLD node in the subgraph is traversed, and when there is an unprocessed node, the relative path of the target file on the unprocessed node is parsed to obtain the last-level directory as the value of the node in the data structure diagram. If it is empty, the root is used as the value; in the data structure diagram, it is searched whether a directory node of the file path already exists. If it exists, the file node and the directory node are added to the link of the directory node. If it does not exist, an empty directory node is created, and the file node and the directory node are added to the link of the created directory node; the DAG construction module is called to store the nodes in the data structure diagram in the data storage module in a protocol buffer serialized manner, and the root identification information of the root node is returned. Here, as Figure 4As shown, first, in step 1), create a root directory node and put it into the map, which is a data structure diagram of the IPLD node for storing the Merkle tree; step 2), traverse the file nodes in the subgraph to check whether there are unprocessed nodes. If the judgment is true, go to step 3), otherwise go to step 6); step 3), parse the relative path of the file, get the last level directory as the key of the map, if it is empty, use root as the key; step 4), find out whether the directory node already exists in the map, if it exists, add the current resource node to the link of the directory node, otherwise create an empty directory node, add the current resource node to the link of the directory node, and the current resource includes the current file node and directory node; step 5), if the directory is empty, go to step 2), otherwise delete the last level directory and go to step 3); step 6), call the Add method of the DAGService module to store the nodes in the map in the data storage module in the protocol buffer serialization mode; step 7), return the CID of the root node.

[0078] Figure 5 A schematic flow chart of a method for restoring a data set according to another aspect of the present application is shown, the method comprising: steps S21 to S24, wherein:

[0079] In step S21, the root identification information of all slice sub-root graphs is downloaded from a system that supports the IPLD data structure; in step S22, the file directory storing the large data set is traversed, and if there are unprocessed files, it is determined whether the unprocessed files are file fragments; then, in step S23, if so, a file fragment is taken out from the unprocessed file, and the root identification information of all slice sub-root graphs is searched for the remaining file fragments under the same file according to the file path of the taken file fragment, wherein the file path includes a specified suffix; in step S24, all fragment files under the same file are restored into one file according to the sequence.

[0080] Here, if Figure 6As shown, all the contents of the root CID of the slice of the large data set are downloaded from the system that supports the IPLD data structure. The system that supports the IPLD data structure is, for example, the IPFS system or IPFS-like systems such as Filecoin and Crust; the file directory of the large data set is traversed to check whether there are unprocessed files. If not, it means that the restoration is completed. If so, it is determined whether it is a file fragment. If not, the file directory is traversed to continue to take out the next unprocessed file. If it is a file fragment, the file fragment is taken out, and the remaining file fragments are searched according to the path of the file fragment. The specific search is performed according to the specified suffix in the path. When slicing the file, a special suffix is ​​added to the path of the generated file fragment, which is used to distinguish whether it is a file fragment during restoration. The format of the special suffix is, for example: original file name-total-total number of fragments-part-fragment sequence number. For example, the ex.jpg file is divided into two file fragments: ex.jpg-total-2-part-1 and ex.jpg-total-2-part-2. Then, all the file fragments of the same file are merged into one file according to the order obtained by parsing the fragment sequence number in the special suffix, and the file directory is traversed to find the next unprocessed file until all the files in the file directory are restored.

[0081] Specifically, in a system that supports the IPLD data structure, a DAG path is constructed for the file shard relative to the root identification information of each large data set shard; and the root identification information of all slice sub-root graphs is downloaded according to the DAG path. Here, when extracting a file of a large data set and it is in multiple large data set shards, it is necessary to first construct a DAG path for the file shard relative to the root CID of each large data set shard, and then download it, and then use the above-mentioned restoration steps to restore the file. When a file of the extracted large data set is in a single large data set shard, a DAG path for the file relative to the root CID of the large data set shard is constructed, and then it is downloaded, and the restoration is completed directly after downloading.

[0082] Through the method of splitting and restoring the data set in the above embodiment of the present application, the size of the data set slices can be made basically consistent, and the complete files in a slice can be used directly after downloading, retaining the original directory hierarchy structure; at the same time, without downloading the file, the view in the slice can be quickly extracted, the directory and file name therein can be browsed, and then a file can be extracted according to the DAG path.

[0083] In addition, an embodiment of the present application further provides a computer-readable medium on which computer-readable instructions are stored. The computer-readable instructions can be executed by a processor to implement the aforementioned method for segmenting and restoring a data set.

[0084] In one embodiment of the present application, a device for segmenting a data set is also provided, the device comprising:

[0085] one or more processors; and

[0086] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the method as described above.

[0087] For example, the computer readable instructions, when executed, cause the one or more processors to:

[0088] Traverse the file directory storing the large data set, and store the information of each file obtained through the traversal into a file list, wherein the information of each file includes the file path, file name and file size;

[0089] Acquire information of the current file to be processed from the file list, and determine the file path to be added to the target file in the subgraph according to the set comparison condition and the information of the current file to be processed;

[0090] The target file is converted into an IPLD node, and a Merkle tree is constructed relative to the file directory according to the file path of the target file on each node using the IPLD node to generate root identification information of the slice sub-root graph.

[0091] In an embodiment of the present application, a device for restoring a data set is also provided, the device comprising:

[0092] one or more processors; and

[0093] A memory storing computer readable instructions, which, when executed, cause the processor to perform the operations of the method as described above.

[0094] For example, the computer readable instructions, when executed, cause the one or more processors to:

[0095] Download the root identification information of all slice sub-root graphs from the system that supports the IPLD data structure;

[0096] Traversing the file directory storing the large data set, if there are unprocessed files, determining whether the unprocessed files are file fragments;

[0097] If yes, take out a file fragment from the unprocessed file, and search for the remaining file fragments under the same file in the root identification information of all the slice sub-root graphs according to the file path of the taken out file fragment, wherein the file path includes the specified suffix;

[0098] Restore all fragment files under the same file into one file in sequence.

[0099] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

[0100] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.

[0101] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. The program instruction for calling the method of the present application may be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium, and / or stored in a working memory of a computer device that runs according to the program instruction. Here, according to an embodiment of the present application, a device is included, the device including a memory for storing computer program instructions and a processor for executing program instructions, wherein, when the computer program instruction is executed by the processor, the device is triggered to run the method and / or technical solution based on the aforementioned multiple embodiments according to the present application.

[0102] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is defined by the appended claims rather than the above description, and it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The words first, second, etc. are used to indicate names, and do not indicate any particular order.

Claims

1. A method for segmenting a data set. It is characterized in that The method comprises: Traverse the file directory storing the large data set, and store the information of each file obtained through the traversal into a file list, wherein the information of each file includes the file path, file name and file size; Acquire information of the current file to be processed from the file list, and determine the file path to be added to the target file in the subgraph according to the set comparison condition and the information of the current file to be processed; Convert the target file into an IPLD node, use the IPLD node to build a Merkle tree relative to the file directory according to the file path of the target file on each node, and generate root identification information of the slice sub-root graph, wherein the file path of the target file includes a specified suffix; Wherein, determining the file path to be added to the target file in the subgraph according to the set comparison condition and the information of the current file to be processed includes: Compare the total size of the file set in the subgraph and the size of the current file to be processed with the specified slicing threshold; If the total size of the file set in the subgraph plus the size of the current file to be processed is less than the specified slicing threshold, the current file to be processed is used as the target file, and the file path of the current file to be processed is added to the subgraph, and the file to be processed is continued to be obtained from the file list; If the total size of the file collection in the subgraph plus the size of the current file to be processed is greater than the specified slicing threshold, the current file to be processed is segmented according to the specified slicing threshold to obtain file segments, and the start and end offsets of the file segments are recorded. The remaining file parts after the current file to be processed are placed in the file list, and the updated file list is traversed until the target file is obtained.

2. The method according to claim 1, It is characterized in that The method comprises: When traversing the file list, if there is no file to be processed, the file or file fragment in the subgraph is directly switched to an IPLD node.

3. The method according to claim 1, It is characterized in that Convert the target file into an IPLD node, including: Traverse the target files in the subgraph, open the target files, and pass the file contents of the target files to the slicer module in the form of byte streams; In the splitter module, a Splitter is constructed according to the received file byte stream; Pass the constructed Splitter to the DAG construction module; Generate a DAG object of IPLD nodes through the DAG construction module and return the root node of IPLD.

4. The method according to claim 3, It is characterized in that Using the IPLD node to construct a Merkle tree relative to the file directory according to the file path of the target file on each node, including: Create a root directory node of the Merkle tree, and put the root directory node into a data structure diagram of an IPLD node for storing the Merkle tree; Traverse each IPLD node in the subgraph. If there is an unprocessed node, parse the relative path of the target file on the unprocessed node and obtain the last-level directory as the value of the node in the data structure graph. If it is empty, use the root as the value. Searching in the data structure diagram whether a directory node of the file path already exists, if so, adding the file node and the directory node to the link of the directory node, if not, creating an empty directory node, adding the file node and the directory node to the link of the created directory node; The DAG construction module is called to store the nodes in the data structure diagram into the data storage module in the form of protocol buffer serialization, and the root identification information of the root node is returned.

5. The method according to claim 4, It is characterized in that The method comprises: Calculate the number of output slices according to the slice size of the large data set, and determine the number of subgraphs according to the number of slices; The progress of file segmentation in the large data set is determined according to the number of the subgraphs and the root identification information of the generated slice sub-root graph.

6. The method according to claim 1, It is characterized in that The target file includes the original current file to be processed and the file segments obtained after the current file to be processed is segmented. The file paths of the file segments in the target file include the specified suffix.

7. A method for restoring a data set in conjunction with the method for segmenting a data set according to claim 1, It is characterized in that The method comprises: Download the root identification information of all slice sub-root graphs from the system that supports the IPLD data structure; Traversing the file directory storing the large data set, if there are unprocessed files, determining whether the unprocessed files are file fragments; If yes, take out a file fragment from the unprocessed file, and search for the remaining file fragments under the same file in the root identification information of all the slice sub-root graphs according to the file path of the taken out file fragment, wherein the file path includes the specified suffix; Restore all fragment files under the same file into one file in sequence.

8. The method according to claim 7, It is characterized in that Download the root identification information of all slice sub-root graphs from the system that supports the IPLD data structure, including: Construct a DAG path for file shards relative to the root identification information of each large data set shard in a system that supports the IPLD data structure; Download the root identification information of all slice sub-root graphs according to the DAG path.

9. A device for segmenting a data set, It is characterized in that The device comprises: one or more processors; and A memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the method as claimed in any one of claims 1 to 6.

10. A device for restoring a data set, It is characterized in that The device comprises: one or more processors; and A memory storing computer readable instructions which, when executed, cause the processor to perform the operations of the method of claim 7 or 8.

11. A computer-readable medium having computer-readable instructions stored thereon, wherein the computer-readable instructions can be executed by a processor to implement the method according to any one of claims 1 to 8.