A target document processing method, device and equipment

CN117312481BActive Publication Date: 2026-08-11ALIPAY (HANGZHOU) INFORMATION TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-06
Publication Date
2026-08-11

AI Technical Summary

Technical Problem

这种方案中,在完整文档的数据量比较大以及文档使用用户的数量比较多的时候,文档同步过程不仅需要消耗大量的设备资源,并且同步耗时也较长

Benefits of technology

[0043]A hash tree for the target document is pre-constructed, with leaf nodes representing hash values ​​generated from partial document data within the target document, and parent nodes representing hash values ​​generated from their child nodes. After determining the differences between the first tree structure of the target document's hash tree on the user device and the second tree structure on the server, the document data corresponding to the changed leaf nodes can be used as the document difference data between the target document on the server and the user device. Document synchronization is achieved by transmitting this document difference data from the target document on the server to the user device. Since it eliminates the need to send the latest version of the complete target document from the server to the user device, it reduces the device resources and time required for document synchronization, as well as the bandwidth load, thereby improving document synchronization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117312481B_ABST
    Figure CN117312481B_ABST
Patent Text Reader

Abstract

This specification discloses a target document processing method, apparatus, and device in its embodiments. The scheme may include: pre-constructing a hash tree of the target document, and setting the leaf nodes of the hash tree to hash values ​​generated based on partial document data in the target document; and setting any parent node in the hash tree to hash values ​​generated based on each of its child nodes. Thus, after determining the difference data between the first tree structure data of the target document's hash tree at the user device and the second tree structure data of the target document's hash tree at the server, the document data corresponding to the changed leaf nodes can be used as the document difference data between the target document at the server and the user device; document synchronization is achieved by transmitting this document difference data from the target document at the server to the user device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of collaborative document technology, and in particular to a method, apparatus and device for processing target documents. Background Technology

[0002] As modern work styles increasingly emphasize teamwork and information sharing, collaborative document technology has emerged, allowing multiple users to simultaneously edit and view the same document over a network. Currently, users can edit collaborative documents locally on their devices and then transmit the latest document data to a cloud server. The cloud server then sends the revised, complete document to other users, enabling them to view the latest, complete document. However, in this approach, when the complete document is large and the number of users is significant, the document synchronization process not only consumes substantial device resources but also takes a considerable amount of time.

[0003] Therefore, how to reduce the device resources and time required for user synchronization of collaborative documents has become an urgent technical problem to be solved. Summary of the Invention

[0004] The embodiments of this specification provide a target document processing method, apparatus, and device that can reduce the equipment resources and time required for user synchronization of collaborative documents.

[0005] To solve the above-mentioned technical problems, the embodiments in this specification are implemented as follows:

[0006] This specification provides a target document processing method, applied to a server, wherein the leaf nodes of the target document's hash tree are hash values ​​generated based on document data in the target document, and any parent node in the target document's hash tree is a hash value generated based on each child node of that parent node; the method includes:

[0007] Obtain the first tree structure data of the hash tree of the target document at the user device;

[0008] Determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server;

[0009] Based on the difference data between the first tree structure data and the second tree structure data, the document difference data between the target document at the server and the target document at the user device is determined;

[0010] Send the document difference data within the target document from the server to the user device.

[0011] This specification provides a target document processing method applied to a user device, wherein the leaf nodes of the target document's hash tree are hash values ​​generated based on document data in the target document, and any parent node in the target document's hash tree is a hash value generated based on each child node of that parent node; the method includes:

[0012] Obtain the first tree structure data of the hash tree of the target document at the user device;

[0013] Send a target document synchronization request carrying the first tree structure data to the server;

[0014] The server receives document difference data in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the user device, determined by the server from within the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0015] The target document at the user device is updated using the document difference data.

[0016] This specification provides a target document processing apparatus applied to a server. The leaf nodes of the target document's hash tree are hash values ​​generated from document data within the target document, and any parent node in the hash tree is a hash value generated from each of its child nodes. The apparatus includes:

[0017] The first acquisition module is used to acquire the first tree structure data of the hash tree of the target document at the user device.

[0018] The first determining module is used to determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0019] The second determining module is used to determine the document difference data between the target document at the server and the target document at the user device based on the difference data between the first tree structure data and the second tree structure data;

[0020] The first sending module is used to send the document difference data in the target document at the server to the user device.

[0021] This specification provides a target document processing apparatus applied to a user device. The leaf nodes of the target document's hash tree are hash values ​​generated from document data within the target document, and any parent node in the hash tree is a hash value generated from each of its child nodes. The apparatus includes:

[0022] The acquisition module is used to acquire the first tree structure data of the hash tree of the target document at the user device;

[0023] The sending module is used to send a target document synchronization request carrying the first tree structure data to the server.

[0024] A receiving module is configured to receive document difference data fed back by the server in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the user device determined by the server from within the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server;

[0025] An update module is used to update the target document on the user device using the document difference data.

[0026] This specification provides an embodiment of a target document processing device, which is a server-side device. The leaf nodes of the target document's hash tree are hash values ​​generated based on the document data in the target document. Any parent node in the target document's hash tree is a hash value generated based on each of the parent node's child nodes, including:

[0027] At least one processor; and,

[0028] A memory communicatively connected to the at least one processor; wherein,

[0029] The memory stores instructions that can be executed by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0030] Obtain the first tree structure data of the hash tree of the target document at the user device;

[0031] Determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the device;

[0032] Based on the difference data between the first tree structure data and the second tree structure data, determine the document difference data between the target document at the device and the target document at the user device;

[0033] Send the document difference data within the target document at the device to the user device.

[0034] This specification provides an embodiment of a target document processing device, which is a user device. The leaf nodes of the hash tree of the target document are hash values ​​generated based on document data in the target document. Any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node, including:

[0035] At least one processor; and,

[0036] A memory communicatively connected to the at least one processor; wherein,

[0037] The memory stores instructions that can be executed by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0038] Obtain the first tree structure data of the hash tree of the target document at the device;

[0039] Send a target document synchronization request carrying the first tree structure data to the server;

[0040] The server receives document difference data in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the device, determined by the server from the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0041] The target document at the device is updated using the document difference data.

[0042] At least one embodiment provided in this specification can achieve the following beneficial effects:

[0043] A hash tree for the target document is pre-constructed, with leaf nodes representing hash values ​​generated from partial document data within the target document, and parent nodes representing hash values ​​generated from their child nodes. After determining the differences between the first tree structure of the target document's hash tree on the user device and the second tree structure on the server, the document data corresponding to the changed leaf nodes can be used as the document difference data between the target document on the server and the user device. Document synchronization is achieved by transmitting this document difference data from the target document on the server to the user device. Since it eliminates the need to send the latest version of the complete target document from the server to the user device, it reduces the device resources and time required for document synchronization, as well as the bandwidth load, thereby improving document synchronization efficiency. Attached Figure Description

[0044] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0045] Figure 1 This is a schematic diagram illustrating an application scenario of a target document processing method provided in the embodiments of this specification;

[0046] Figure 2 A flowchart illustrating a target document processing method provided in an embodiment of this specification;

[0047] Figure 3 A schematic diagram of a hash tree for a target document provided in an embodiment of this specification;

[0048] Figure 4 A schematic diagram of a hash tree for another target document provided in an embodiment of this specification;

[0049] Figure 5 A flowchart illustrating another target document processing method provided in the embodiments of this specification;

[0050] Figure 6 The embodiments provided in this specification correspond to Figure 2 and Figure 5 A swimlane flowchart illustrating the target document processing method in the diagram.

[0051] Figure 7 The embodiments provided in this specification correspond to Figure 2A schematic diagram of the structure of a target document processing device;

[0052] Figure 8 The embodiments provided in this specification correspond to Figure 5 A schematic diagram of the structure of a target document processing device;

[0053] Figure 9 The embodiments provided in this specification correspond to Figure 2 A schematic diagram of the structure of a target document processing device;

[0054] Figure 10 The embodiments provided in this specification correspond to Figure 5 A schematic diagram of the structure of a target document processing device. Detailed Implementation

[0055] To make the objectives, technical solutions, and advantages of one or more embodiments of this specification clearer, the technical solutions of one or more embodiments of this specification will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of them. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort are within the protection scope of one or more embodiments of this specification.

[0056] The technical solutions provided in the various embodiments of this specification are described in detail below with reference to the accompanying drawings.

[0057] In existing technologies, while multi-person collaborative documents can significantly improve team collaboration efficiency, when users need to synchronize documents, the latest version of the complete document needs to be sent to each collaborator. When the document data volume is large and there are many collaborators, the document synchronization process will not only consume a lot of device resources, but also consume a lot of server bandwidth. This will result in a long time for collaborators' devices to load the latest version of the document, leading to lag and affecting the user experience.

[0058] To address the shortcomings of existing technologies, this solution provides the following embodiments:

[0059] Figure 1 This is a schematic diagram of the overall scheme flow of a target document processing method in the embodiments of this specification.

[0060] like Figure 1 As shown, the server 14 used to manage the target document can communicate with the user devices of each collaborator of the target document (e.g., device 11, device 12, device 13) to realize the creation, updating and synchronization of the target document.

[0061] Specifically, the leaf nodes of the hash tree of the target document can be hash values ​​generated from the document data in the target document, and any parent node in the hash tree of the target document can be a hash value generated from each of the child nodes of that parent node. The server typically stores the latest version of the tree structure data of the hash tree of the target document, as well as the latest version of the complete target document.

[0062] When user synchronization is required for the latest version of a target document at server 14, server 14 can obtain the first tree structure data of the hash tree of the target document at the user device (e.g., device 11, device 12, or device 13). The difference data between this first tree structure data and the second tree structure data of the hash tree of the target document at server 14 (i.e., the tree structure data of the latest version) can be determined. Based on the difference data between the first and second tree structure data, the document difference data between the latest version of the target document at server 14 and the target document at the user device can be determined. By sending the document difference data within the target document at server 14 to the user device, the document synchronization process can be achieved without sending the complete latest version of the target document at server 14 to the user device. This helps reduce the device resources and time consumed in the document synchronization process, and also helps reduce the bandwidth load required for the document synchronization process, thereby improving document synchronization efficiency.

[0063] Next, a target document processing method provided in the embodiments of the specification will be described in detail with reference to the accompanying drawings:

[0064] Figure 2 This is a flowchart illustrating a target document processing method provided in an embodiment of this specification. From a programming perspective, the entity executing this process can be a server for managing target documents, or an application running on the server for managing target documents. Figure 2 As shown, the process may include the following steps:

[0065] Step 202: Obtain the first tree structure data of the hash tree of the target document at the user device.

[0066] In this embodiment of the specification, the target document can be a collaborative document, that is, a document that allows multiple collaborators to read, write, update, and modify simultaneously. The user device can be the device used by the collaborators of the target document when reading, writing, updating, and modifying the target document.

[0067] In practical applications, collaborators can specifically include: creators, updaters, and synchronizers of the target document, and the same collaborator can have one or more of these roles. A creator refers to the party that creates the target document; typically, there is only one creator for the same target document. An updater refers to the party that modifies the target document; there can be zero or more updaters for the same target document. A synchronizer refers to the party that initiates a synchronization request to the server to update the target document it owns; there can be multiple synchronizers for the same target document.

[0068] In this embodiment, a hash tree is a tree-like data structure in cryptography and computer science. Each leaf node is labeled with the hash of a data block, while nodes other than leaf nodes are labeled with the cryptographic hashes of their child node labels. Based on this, to efficiently and securely verify whether the latest version of the target document stored on the server is consistent with the target document currently held locally on the user device of the document collaborator, and thus determine whether it is necessary to synchronize the latest version of the target document from the server to the collaborator, a hash tree of the target document can be created. The leaf nodes of the hash tree can be hash values ​​generated from the document data in the target document, and any parent node in the hash tree can be a hash value generated from each of the child nodes of that parent node.

[0069] Furthermore, both the server and the user's device can store the hash tree structure data, which is consistent with the document data of the target document they currently possess. Therefore, when user synchronization of the target document is required, the collaborator's user device can send the first tree structure data of the target document's hash tree stored locally on the device to the server.

[0070] Specifically, the first tree structure data may include node data of at least some nodes in the hash tree of the target document locally owned by the user device. In addition, it may include the node's unique identifier and lineage information with other nodes. In practical applications, if these nodes are leaf nodes, the node data in the first tree structure data can be the hash value of the document data within the target document corresponding to that leaf node. If these nodes are not leaf nodes, the node data in the first tree structure data can be the hash value generated from the node data of each of the node's child nodes.

[0071] Step 204: Determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0072] In the embodiments of this specification, the second tree structure data of the hash tree of the target document at the server is usually generated based on the document data of the latest version of the target document at the server. By comparing whether the node data of the same node in the first tree structure data and the second tree structure data are consistent, the difference data in the first tree structure data and the second tree structure data can be identified.

[0073] Step 206: Based on the difference data between the first tree structure data and the second tree structure data, determine the document difference data between the target document at the server and the target document at the user device.

[0074] In this embodiment, the difference data between the first tree structure data and the second tree structure data reflects the leaf nodes that differ in the hash trees of the target documents at the server and the user device. The document data in the target documents corresponding to these differing leaf nodes is the document difference data between the two. It can be understood that if the node data of the same leaf node in the first tree structure data and the second tree structure data are consistent, it indicates that the document data corresponding to that leaf node in the target document at the server is consistent with the document data corresponding to that leaf node in the target document at the user device. Therefore, it is unnecessary to send the document data corresponding to that leaf node in the target document at the server to the user device. In this case, the document difference data determined in step 206 will not include the document data corresponding to that leaf node.

[0075] Step 208: Send the document difference data in the target document from the server to the user device.

[0076] In this embodiment of the specification, after the server sends the document difference data in the target document to the user device, the user device can use the document difference data to replace the document data within the document data range corresponding to the leaf node to which the document difference data belongs in the local target document. This enables the updated target document on the user device to be consistent with the latest version of the target document on the server, thereby achieving document synchronization.

[0077] Figure 2The method described above accurately identifies document differences between the target documents on the server and the user device by analyzing the differences in the hash tree structure data of the target documents on the server and the user device. Document synchronization is then achieved by sending these document differences from the target document on the server to the user device. Since it eliminates the need to send the latest version of the complete target document from the server to the user device, it reduces the device resources and time consumed during document synchronization, and also reduces the bandwidth load required for the document synchronization process, thereby improving document synchronization efficiency.

[0078] based on Figure 2 In addition to the method described in the embodiments of this specification, some specific implementation schemes of the method are also provided, which will be described below.

[0079] The embodiments in this specification also provide an implementation method for enabling users to create target documents.

[0080] Specifically, before step 202: obtaining the first tree structure data of the hash tree of the target document at the user device, it may further include:

[0081] Obtain a creation request for the target document; the creation request carries the first document size and the number of first leaf nodes of the target document.

[0082] In response to the creation request, a hash tree of the target document is created to obtain the initial tree structure data of the hash tree of the target document; the initial tree structure data includes the lineage information between the nodes in the hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the hash tree; wherein, the first document data range is determined based on the first document capacity and the number of the first leaf nodes.

[0083] Send the initial tree structure data of the hash tree of the target document to the user device.

[0084] In the embodiments of this specification, when creating a target document, the user typically needs to pre-specify the maximum size of the target document (i.e., the first document size) and the number of leaf nodes that the hash tree of the target document should have (i.e., the first leaf node number). This is to facilitate determining the document data range in the target document corresponding to each leaf node based on the above information, and to automatically generate other nodes in the hash tree of the target document. In practical applications, the first document size and the first leaf node number can be determined according to actual needs. For example, the first document size and the first leaf node number can be 100 MB and 100, or they can be 10 MB and 5, etc., without specific limitations. The aforementioned request to create the target document can be either a request sent by the user device to the server or a request generated by the server itself, without specific limitations.

[0085] To facilitate understanding of the principles behind creating a hash tree for a target document, and the specific meaning of a hash tree for a target document, a more detailed implementation method for creating a hash tree for a target document is provided here.

[0086] Specifically, the step of creating a hash tree for the target document in response to the creation request may include:

[0087] Based on the first document capacity and the first leaf node number, the range of first document data in the target document corresponding to each leaf node in the hash tree is determined; wherein, the capacity of the first document data range is the quotient of the first document capacity and the first leaf node number.

[0088] The leaf nodes in the hash tree are sorted according to the order of the first document data range from front to back to obtain the leaf node sequence.

[0089] A predetermined number of adjacent leaf nodes in the leaf node sequence are divided into child nodes at the same parent node to obtain a parent node sequence; wherein, any leaf node has one parent node.

[0090] If the number of nodes in the parent node sequence is equal to one, then further parent node partitioning is prohibited for the nodes in the parent node sequence, thus obtaining the hash tree of the target document.

[0091] If the number of nodes in the parent node sequence is greater than one, then the nodes in the parent node sequence are further divided into parent nodes until the number of nodes in the updated parent node sequence is one, thus obtaining the hash tree of the target document.

[0092] To facilitate understanding, an example is provided to illustrate the above process. Figure 3This is a schematic diagram of a hash tree for a target document provided in an embodiment of this specification. Assuming the first document capacity and the number of first leaf nodes are 10 MB and 5 respectively, when the capacity of the first document data range corresponding to each leaf node is consistent, it can be seen that the capacity of the first document data range corresponding to each leaf node can be 2 MB. In this case, the first document data ranges corresponding to the first leaf nodes, such as nodes D304, E305, F306, G307, and H308, can be respectively: the first 2 MB of the target document, the 3rd to 4th MB, the 5th to 6th MB, the 7th to 8th MB, and the 9th to 10th MB. Then, by sorting the leaf nodes according to the order of the first document data range from front to back, the resulting leaf node sequence is: node D304, node E305, node F306, node G307, and node H308.

[0093] Assuming the preset number of parent nodes used when partitioning the first leaf node is 3, then nodes D304, E305, and F306 can be assigned to the same parent node (i.e., node B302), and nodes G307 and H308 can be assigned to the same parent node (i.e., node C303). At this point, the resulting parent node sequence contains two nodes, B302 and C303. Since the number of nodes in the parent node sequence is greater than 1, the same principle as when partitioning the parent nodes for the first leaf node needs to be applied to partition the parent nodes of each node in the parent node sequence. Specifically, since the number of nodes in the parent node sequence (i.e., 2) is less than the preset number (i.e., 3), the two nodes in the parent node sequence can be directly assigned to the same parent node (i.e., node A301). It can be seen that after this parent node partitioning, the updated parent node sequence contains exactly one node (i.e., node A301), so we can stop further parent node partitioning and use the currently generated hash tree as the hash tree of the target document.

[0094] It is understandable that the capacity of the first document data range in the target document corresponding to each leaf node in the hash tree can be the same or different. For example, in the above example, the first document data ranges corresponding to the first leaf nodes such as nodes D304, E305, F306, G307, and H308 can be respectively: the first 3 MB of space in the target document, the 4 MB, the 5 MB, the 6 MB to 7 MB, and the 8 MB to 10 MB. No specific limitation is made in this regard. Furthermore, the preset number of parent nodes used when partitioning leaf nodes and nodes in each parent node sequence can be the same or different. This preset number is usually a value greater than 1, and no specific limitation is made in this regard either.

[0095] In practical applications, the first document data range of the target document corresponding to the first leaf node may or may not contain document data, and this often needs to be determined based on the actual situation, without specific limitations. For example, when the target document is initially created, it is empty and contains no document data at all. At this time, the document data corresponding to each first leaf node is empty. However, as the user edits the content of the target document, the document data within the target document continuously increases. If the amount of document data in the target document is 3 MB at this time, and the first document data ranges corresponding to the first leaf nodes such as node D304 and node E305 are respectively: the first 2 MB of space in the target document, and the third to fourth MB of space, then the first 2 MB of document data in the target document is the document data within the first document data range of the target document corresponding to node D304. Based on this, the node data of node D304 can be the hash value of the first 2 MB of document data in the target document. The last megabyte of document data in the target document (i.e., the document data other than the first 2 megabytes of document data) is the document data within the first document data range of the target document corresponding to node E305. At this time, the node data of node E305 can be the hash value of the last megabyte of document data in the target document.

[0096] In the embodiments described in this specification, after the user creates the target document, there may be a need to expand or shrink the target document. In this case, it is usually necessary to adjust the hash tree of the target document to ensure the normal operation of the target document.

[0097] To facilitate understanding, the implementation method for expanding the target document is given here.

[0098] Specifically, after creating the hash tree of the target document in response to the creation request, the process may further include:

[0099] Obtain a scaling request for the target document; the scaling request carries information for determining the required additional second document capacity and the number of second leaf nodes for the target document.

[0100] In response to the expansion request, based on the latest version of the hash tree structure data of the target document at the server, the hash tree of the target document is adjusted to obtain the third tree structure data of the expanded hash tree of the target document. The third tree structure data includes the lineage information between the nodes in the expanded hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node count in the expanded hash tree, and the second document data range in the target document corresponding to the number of newly added leaf nodes of the second leaf node count. The second document data range is determined based on the second document capacity and the number of second leaf nodes. Furthermore, the second document data range is the document data range located after the first document data range.

[0101] Determine the first tree structure difference data between the third tree structure data and the latest version tree structure data.

[0102] Send a first target document update instruction carrying the first tree structure difference data to the user device.

[0103] In the embodiments of this specification, to reduce the amount of data synchronized to each collaborator required for document expansion, the adjustments to the hash tree of the target document should generally be minimized. Based on this, the existing lineage relationships between nodes in the target document's hash tree can be maintained, and the expanded document data range can be allocated to these new leaf nodes. The principle for determining the second document data range corresponding to each new leaf node can be consistent with the principle for determining the first document data range corresponding to the original first leaf node. Similarly, the principle for dividing the parent nodes at each level for each new leaf node can be consistent with the principle for dividing the parent nodes at each level for the original first leaf node in the target document.

[0104] To facilitate understanding, an example is provided to illustrate the above process. Figure 4 A schematic diagram of another target document hash tree provided for embodiments of this specification, such as... Figure 4As shown, assuming the target document requires an additional 6 MB of second document capacity and 2 second leaf nodes, and continuing the previous example, the target document's original capacity was 10 MB, then the target document's capacity needs to be changed to 16 MB. If nodes D to H correspond to the first 10 MB of the target document's space, then two new leaf nodes need to be added (i.e., nodes J402 and K403). The second document data ranges in the target document corresponding to nodes J402 and K403 can be set as the 11th-13th MB space and the 14th-16th MB space of the target document, respectively. When partitioning the parent nodes for the newly added nodes J402 and K403, nodes J402 and K403 can be directly assigned to the same parent node (i.e., node I401), and the parent node of node I401 is determined to be node A301.

[0105] In this embodiment of the specification, as the document data of the target document is continuously updated, the node data of some nodes in the hash tree of the target document will change. However, the lineage information between the nodes usually does not change. Therefore, when it is necessary to expand the target document, it is necessary to adjust the tree structure data based on the latest version of the target document's hash tree on the server to obtain the third tree structure data of the expanded hash tree of the target document. The lineage information between the nodes reflects whether a node is a child or parent node of another node.

[0106] In practical applications, since the node data and lineage information of the same nodes contained in the expanded hash tree are usually consistent with those in the original hash tree, the difference in the first tree structure data between the third tree structure data of the expanded hash tree and the latest version tree structure data of the original hash tree can usually include: the node data of each newly added node in the expanded hash tree, the lineage information between each newly added node in the expanded hash tree, and the lineage information between each newly added node in the expanded hash tree and other original nodes.

[0107] Combination Figure 4 In the example shown, the first tree structure difference data may include: node data of nodes J402, K403, and I401; lineage information among nodes J402, K403, and I401; and lineage information between node I401 and node A301. In practical applications, since the document data of the target document corresponding to the newly added leaf node is usually empty, the node data of nodes J402, K403, and I401 are usually all 0, thus ensuring that the node data of node A301 does not change, and therefore, the node data of node A301 will not be used as the first tree structure difference data.

[0108] In this embodiment of the specification, the server may also send a first target document update instruction carrying the first tree structure difference data to the user device of the collaborator of the target document. In response to the first target document update instruction, the user device may add the first tree structure difference data to the tree structure data of the hash tree of the target document stored locally, so that the tree structure data of the hash tree of the target document stored on the user device is consistent with the tree structure data of the hash tree of the target document stored on the server, which helps to ensure the consistency of the target document used by each collaborator.

[0109] In the embodiments described in this specification, a method for scaling down the target document is given.

[0110] Specifically, after creating the hash tree of the target document in response to the creation request, the process may further include:

[0111] Obtain a scaling-down request for the target document; the scaling-down request carries information for determining the required reduction in the size of a third document for the target document.

[0112] In response to the scaling-down request, based on the latest version tree structure data of the target document's hash tree at the server, the hash tree of the target document is adjusted to obtain the fourth tree structure data of the scaled-down hash tree of the target document. The fourth tree structure data contains the lineage information between the nodes in the scaled-down hash tree, and the range of the first document data in the target document corresponding to the leaf nodes of the fourth leaf node count in the scaled-down hash tree. The fourth leaf node count is the difference between the first leaf node count and the number of third leaf nodes to be reduced based on the third document capacity.

[0113] Determine the second tree structure difference data between the fourth tree structure data and the latest version tree structure data.

[0114] Send a second target document update instruction carrying the difference data of the second tree structure to the user device.

[0115] In the embodiments of this specification, in order to reduce the amount of data that needs to be synchronized to each collaborator for document shrinking, the adjustment content of the hash tree of the target document should generally be minimized. Based on this, the size of the target document can be reduced to the specified size by deleting the leaf nodes at the end of the corresponding document data range in the target document.

[0116] Specifically, the leaf nodes can be sorted from back to front according to the document data range corresponding to each leaf node in the latest version of the hash tree on the server to obtain the target leaf node sequence. If the sum of the document data ranges of the first N leaf nodes in the target leaf node sequence is less than the third document capacity, and the sum of the document data ranges of the first N+1 leaf nodes is greater than the third document capacity, then the first N leaf nodes are deleted, and the document data range of the N+1th leaf node is reduced to the difference between the third document capacity and the document data range of the first N leaf nodes. Conversely, if the sum of the document data ranges of the first N leaf nodes in the target leaf node sequence is less than the third document capacity, and the sum of the document data ranges of the first N+1 leaf nodes is equal to the third document capacity, then the first N+1 leaf nodes are deleted.

[0117] For ease of understanding, combined with Figure 3 The following example illustrates the scaling-down process. Assume the leaf nodes in the latest version of the hash tree on the server are nodes D304, E305, F306, G307, and H308. The document data ranges corresponding to these five leaf nodes in the target document are: the first 2 MB, the 3rd to 4th MB, the 5th to 6th MB, the 7th to 8th MB, and the 9th to 10th MB, respectively. If a reduction of 3 MB in the third document size is required, node H308 needs to be deleted, and the document data range corresponding to node G307 needs to be adjusted to the 7th MB size. If a reduction of 4 MB in the third document size is required, both nodes H308 and G307 need to be deleted.

[0118] In addition, when only node H308 needs to be deleted, since node H308's parent node (i.e., node C303) also has child nodes belonging to leaf nodes (e.g., node G307), node C303 does not need to be deleted. However, if both nodes H308 and G307 need to be deleted, since their parent node (i.e., node C303) does not have child nodes belonging to leaf nodes, node C303 can also be deleted. This helps reduce the number of nodes that need to be queried for differences during data synchronization, thereby reducing the waste of device resources.

[0119] In practical applications, the difference in the second tree structure between the fourth tree structure data of the scaled-down hash tree and the latest version tree structure data of the hash tree before scaling down typically includes at least: the lineage information between the nodes reduced in the scaled-down hash tree, and the lineage information between the nodes reduced in the scaled-down hash tree and other retained nodes.

[0120] In practical applications, if the document data corresponding to each of the removed leaf nodes is empty, the node data of each of the removed leaf nodes is usually 0. This ensures that even if these leaf nodes are deleted, it will not affect the node data of the remaining nodes. In this case, the second tree structure difference data may not contain node data. However, if the document data corresponding to the removed leaf node is not empty, the node data of other nodes directly related to that leaf node will also change. This allows the second tree structure difference data to include the changed node data of the remaining nodes whose node data has changed due to the deletion of that leaf node. For example, assuming that only node H308 needs to be deleted, and the document data corresponding to node H308 is not empty, the changed node data of nodes C303 and A301 are usually also included in the second tree structure difference data. However, if the document data corresponding to node H308 is empty, the second tree structure difference data may not contain the node data of any node.

[0121] In this embodiment of the specification, the server can also send a second target document update instruction carrying the second tree structure difference data to the user device of the collaborator of the target document. In response to the second target document update instruction, the user device can delete the lineage information between nodes carried in the second tree structure difference data in the tree structure data of the hash tree of the target document stored locally. If the second tree structure difference data also includes the modified node data of each node that is retained, the user device can also use the modified node data to replace the corresponding node data that it has locally, so that the tree structure data of the hash tree of the target document stored on the server is consistent with that of the user device, which helps to ensure the consistency of the target document used by each collaborator.

[0122] In the embodiments described in this specification, since the collaborator modifies the document data of the target document locally on the user's device, it is usually necessary to update the target document on the server to ensure the accuracy of the target document on the server. Based on this, Figure 2 The method described herein may further include:

[0123] Obtain an update request for the target document sent by the user equipment; the update request carries the modified document data corresponding to the target leaf node in the target document at the user equipment that has changed due to the document modification operation.

[0124] In response to the update request, the target document and the tree structure data of the hash tree of the target document at the server are updated based on the changed document data.

[0125] In this embodiment, the user device locally stores a specified version of the target document synchronized from the server, along with the tree structure data of the target document's hash tree. When a user performs a document modification operation on the target document on the user device, the node data of some leaf nodes in the target document's hash tree may change. In this case, it is necessary to determine the currently existing document data within the document data range corresponding to the changed target leaf node as the modified document data. By sending the modified document data and the unique node identifier of the target leaf node to the server, the server can use the modified document data to replace the data within the document data range corresponding to the target leaf node in the target document locally on the server, thereby achieving the update of the target document on the server.

[0126] In addition, the server can either calculate the changed node data of the target leaf node itself based on the changed document data, or the user device can directly report the changed node data of the target leaf node to the server, so that the server can use the changed node data to replace the corresponding node data in the hash tree of the target document at the server, thereby updating the hash tree of the target document at the server.

[0127] For ease of understanding, combined with Figure 3 To illustrate this, consider the following example. Assume a user's device locally stores a target document of a specified version synchronized from the server. The document data range corresponding to node D304 already contains 2 MB of document data, while the document data range corresponding to node E305 contains only 1 MB. If the user appends 0.5 MB of document data to the existing document data corresponding to node E305, only the document data within the document data range corresponding to node E305 has changed. In this case, all document data within the document data range corresponding to node E305 can be considered the changed document data.

[0128] If a user adds 1.5 MB of document data after the existing document data corresponding to node E, then not only has the document data within the document data range corresponding to node E305 changed, but also 0.5 MB of document data has been added to the document data range corresponding to node F306. Therefore, all document data within the document data ranges corresponding to nodes E305 and F306 can be used as the changed document data.

[0129] Alternatively, if a user deletes the first 0.5 MB of document data within the document data range corresponding to node D304, and then adds another 0.5 MB of document data within that range, the document data within the document data range corresponding to node E305 may not change. This would allow all document data within the document data range corresponding to node D304 to be considered as the changed document data.

[0130] Alternatively, if a user adds 0.5 MB of document data at a specified position within the document data range corresponding to node D304, the document data range of any existing document data at that specified position will be shifted forward by 0.5 MB. This will also change the document data within the document data range corresponding to node E305. Therefore, all document data within the document data ranges corresponding to nodes D304 and E305 can be considered as the changed document data. Further details are omitted.

[0131] In practical applications, to ensure the stable operation of the target document update process, the server can assign a new version number to the target document each time it is updated. Under normal circumstances, users are only allowed to update the latest version of the target document on the server, and are not allowed to update the target document of the past version on the server, so as to avoid losing the user's effective modifications to the target document.

[0132] Therefore, the update request sent by the user equipment may also carry the previous version information of the target document at the user equipment.

[0133] Correspondingly, in response to the update request, based on the changed document data, the target document and the tree structure data of the hash tree of the target document at the server are updated, specifically including:

[0134] If the version information before the update is consistent with the latest version information of the target document on the server, then in response to the update request, the target document and the tree structure data of the hash tree of the target document on the server are updated based on the changed document data.

[0135] If the version information before the update is inconsistent with the latest version information of the target document on the server, it usually indicates that the user has modified the target document for a historical version. In this case, such modification is invalid, and the server can refuse to update the target document and the tree structure data of the target document's hash tree based on the changed document data.

[0136] To facilitate understanding of the user synchronization process for the target document, a specific implementation method for finding the document difference data that needs to be synchronized to collaborators is also provided.

[0137] Specifically, step 204: determining the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server may include:

[0138] By comparing the node data of the same node in the hash tree of the target document from the root node to the leaf node in the first tree structure data and the second tree structure data to determine whether they are consistent, the leaf nodes in the hash tree that have changed are identified; or,

[0139] By comparing the node data of each leaf node in the hash tree contained in the first tree structure data and the second tree structure data to determine whether they are consistent, the leaf nodes in the hash tree that have changed are identified.

[0140] Correspondingly, step 206: Based on the difference data between the first tree structure data and the second tree structure data, determining the document difference data between the target document at the server and the target document at the user device may include:

[0141] The document data corresponding to the changed leaf node in the target document at the server is determined as the document difference data between the target document at the server and the target document at the user device.

[0142] In the embodiments of this specification, determining the difference data between the first tree structure data and the second tree structure data is essentially to identify the leaf nodes in the hash trees of the target documents at the server and the user device that have differences, and to use the document data within the range of document data corresponding to these leaf nodes in the latest version of the target document at the server as the document difference data; while for leaf nodes in the hash trees of the target documents at the server and the user device that have the same node data, since the document data within the range of document data corresponding to these leaf nodes in the target documents at the server and the user device are consistent, no synchronization is required, and thus they can be prohibited from being used as document difference data.

[0143] In the embodiments of this specification, when determining the difference data between the first tree structure data and the second tree structure data, that is, when determining the changed leaf nodes in the hash tree at the server and user equipment, the filtering can be performed on each level of nodes in the direction from the root node to the leaf node of the hash tree, or the filtering can be performed only on each leaf node itself, which is flexible.

[0144] To facilitate understanding, this section explains the implementation method of filtering step by step from the root node to the leaf node of the hash tree to determine the leaf node that has changed.

[0145] Specifically, the step of comparing the node data of the same node in the hash tree contained in the first tree structure data and the second tree structure data to determine the changed leaf node in the hash tree according to the order from the root node to the leaf node of the hash tree of the target document can include:

[0146] Determine whether the first node data of the root node in the first tree structure data is consistent with the second node data of the root node in the second tree structure data, and obtain a first determination result.

[0147] If the first determination result indicates that the data of the first node is consistent with the data of the second node, then information reflecting that the target document does not have document difference data is generated, that is, the hash tree of the target document does not have any changed leaf nodes; thus, document synchronization is not required. Subsequently, information reflecting that the target document at the server and the user device is consistent and does not require synchronization can also be sent to the user device.

[0148] If the first judgment result indicates that the data of the first node is inconsistent with the data of the second node, then for any first node among the child nodes of the root node, it is determined whether the data of the third node of the first node in the first tree structure data is consistent with the data of the fourth node of the first node in the second tree structure data, and a second judgment result is obtained.

[0149] If the first node is a leaf node, and the second determination result indicates that the data of the third node is inconsistent with the data of the fourth node, then the first node is determined to be a leaf node in the hash tree that has undergone changes.

[0150] If the first node is not a leaf node, and the second judgment result indicates that the data of the third node is inconsistent with the data of the fourth node, then for any second node among the child nodes of the first node, it is determined whether the data of the fifth node of the second node in the first tree structure data is consistent with the data of the sixth node of the second node in the second tree structure data, and a third judgment result is obtained.

[0151] If the second node is a leaf node, and the third judgment result indicates that the data of the fifth node is inconsistent with the data of the sixth node, then the second node is determined to be a leaf node in the hash tree that has undergone changes.

[0152] For ease of understanding, combined with Figure 3 The process of screening leaf nodes that have changed in the hash tree described above is illustrated with an example. For instance... Figure 3As shown, node A301 is the root node. We can first determine if the data of the first node of node A301 on the server side is consistent with the data of the second node of node A301 on the user device. If they are consistent, it indicates that the target document on the server and the user device is consistent, and document synchronization is unnecessary. Therefore, we can proceed to the end without further checking the consistency of node data on other nodes, which saves device resources. If the data of the first node of node A301 on the server side is inconsistent with the data of the second node of node A301 on the user device, then we need to check if the node data of each child node of node A301 (i.e., the first node, for example, node B302 and node C303) are consistent.

[0153] If the data of the third node of node B302 on the server is inconsistent with the data of the fourth node of node B302 on the user device, since node B302 is not a leaf node, it is necessary to check whether the node data of each child node (i.e., the second node, such as node D304, node E305, and node F306) of node B302 are consistent. Assuming that the node data of nodes D304 and E305 on the server and user device are inconsistent, since nodes D304 and E305 are both leaf nodes, they can be identified as leaf nodes that have undergone changes. However, if the node data of node F306 on the server and user device are consistent, then identifying node F306 as a leaf node that has undergone changes can be prevented.

[0154] Assuming that the data of the third node of node C303 on the server is consistent with the data of the fourth node of node C303 on the user device, it means that the document data corresponding to the leaf nodes that affect node C303 in the target document on the server and the user device are consistent. No document synchronization is required, so the process can jump to the end without continuing to identify the consistency of node data for the child nodes of node C303. This helps to reduce the consumption of device resources and improve the efficiency of document synchronization.

[0155] In the embodiments of this specification, the server can obtain the first tree structure data of the hash tree of the target document at the user device in various ways. For example, the user device can send the complete tree structure data of the hash tree of the target document it has locally as the first tree structure data to the server at once, which is convenient and fast. Alternatively, when searching for the leaf node that has changed in the order from the root node to the leaf node, the node data of the node that needs to be compared for data consistency is sent as the first tree structure data to the server, which helps to reduce the consumption of device resources.

[0156] Based on this, step 202: obtaining the first tree structure data of the hash tree of the target document at the user device, specifically may include:

[0157] Obtain a first update status query request for the target document sent by the user equipment; the first update status query request carries node data of each node of the hash tree of the target document at the user equipment; or,

[0158] Obtain a second update status query request for the target document sent by the user equipment; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user equipment.

[0159] Obtain the third update status query request for the target document sent by the user equipment; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user equipment; the third update status query request is a request sent by the user equipment to the server after determining that the first node data is inconsistent with the second node data and that the root node does not belong to a leaf node.

[0160] Obtain the fourth update status query request for the target document sent by the user equipment; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user equipment; the fourth update status query request is a request sent by the user equipment to the server after determining that the third node data is inconsistent with the fourth node data and that the first node is not a leaf node.

[0161] In the embodiments of this specification, the third update status query request is typically a request sent by the user equipment to the server when the first judgment result indicates that the data of the first node is inconsistent with the data of the second node. The server typically needs to determine whether the data of the third node of the first node in the first tree structure data is consistent with the data of the fourth node of the first node in the second tree structure data based on the information carried in the third update status query request, in order to obtain the second judgment result.

[0162] The fourth update status query request is typically sent by the user equipment to the server when the second judgment result indicates that the data of the third node is inconsistent with the data of the fourth node. The server usually needs to use the information carried in the fourth update status query request to determine whether the data of the fifth node of the second node in the first tree structure data is consistent with the data of the sixth node of the second node in the second tree structure data, in order to obtain the third judgment result.

[0163] In practical applications, if the second node is not a leaf node and the data of the fifth node is inconsistent with the data of the sixth node, the user equipment usually needs to continue to send a target update query request to the server, carrying the node data of the child nodes of the second node at the user equipment. This allows the server to continue to identify whether the child nodes of the second node belong to the leaf nodes that have changed, based on the information carried in the target update query request, until all the leaf nodes that have sent changes are found. This will not be elaborated further.

[0164] To facilitate understanding, this section explains the implementation method of simply verifying whether the node data of each leaf node on the server and the user device is consistent, in order to identify leaf nodes that have changed.

[0165] Specifically, comparing whether the node data of each leaf node in the hash tree contained in the first tree structure data and the second tree structure data are consistent, and determining the leaf nodes in the hash tree that have changed, may include:

[0166] For any leaf node in the hash tree of the target document, determine whether the seventh node data of the leaf node contained in the first tree structure data is consistent with the eighth node data of the leaf node contained in the second tree structure data, and obtain the fourth determination result.

[0167] If the fourth determination result indicates that the data of the seventh node is inconsistent with the data of the eighth node, then any leaf node is determined as the leaf node in the hash tree that has changed.

[0168] For ease of understanding, we will still combine Figure 3 The process of screening leaf nodes that have changed in the hash tree described above is illustrated with an example. For instance... Figure 3 As shown, the leaf nodes in the hash tree of the target document are nodes D304, E305, F306, G307, and H308. We can then determine whether the node data of node D304 on the server and user device are consistent. If they are, node D304 can be prevented from being identified as a changed leaf node; otherwise, it can be identified as such. Similarly, we can also identify whether nodes E305, F306, G307, and H308 are changed leaf nodes. Since it's unnecessary to check the consistency of node data in other nodes of the target document's hash tree, this reduces device resource consumption and improves data synchronization efficiency when the number of leaf nodes is small.

[0169] In practical applications, since the document data range corresponding to any leaf node on the server is empty, the document data range of leaf nodes following that leaf node will necessarily be empty. Therefore, it is unnecessary to perform node data consistency comparisons for these leaf nodes with empty document data; it is sufficient to instruct the user device to make the document data range corresponding to these leaf nodes empty. This elimination of the need for node data consistency comparisons for all leaf nodes also helps to further reduce device resource consumption.

[0170] For example, assuming the document data range corresponding to node F306 on the server is empty, it's unnecessary to perform node data consistency comparisons for nodes F306, G307, and H308. Instead, only node data consistency comparisons need to be performed for nodes D304 and E305 to identify the changed leaf nodes in nodes D304 and E305. Subsequently, on one hand, the document difference data corresponding to the changed leaf nodes in the target document on the server can be sent to the user device, allowing the user device to replace the corresponding document data in the local target document using this data. On the other hand, the unique identifier of the leaf node with empty document data on the server can also be sent to the user device, allowing the user device to directly set the document data of the leaf node corresponding to that unique identifier in the local target document to empty, which is both secure and fast.

[0171] In this embodiment of the specification, when only the node data of the leaf nodes in the hash tree is compared for consistency to identify the changed leaf nodes, step 202: obtaining the first tree structure data of the hash tree of the target document at the user equipment may specifically include:

[0172] Obtain the fifth update status query request for the target document sent by the user equipment; the fifth update status query request carries the node data of each leaf node of the hash tree of the target document at the user equipment. Alternatively,

[0173] According to the corresponding document data range from front to back, the node data of each leaf node at the user device is sent to the server one by one until the document data corresponding to the node to be compared for data consistency at the server is empty, which helps to reduce the consumption of device resources.

[0174] Based on and Figure 2 Following the same approach as the solution shown, this specification also provides another method for processing target documents. Figure 5This is a flowchart illustrating another target document processing method provided in an embodiment of this specification. The executing entity of this process can be a user device of a collaborator of the target document, or an application running on the user device. The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node; for example... Figure 5 As shown, the process may include:

[0175] Step 502: Obtain the first tree structure data of the hash tree of the target document at the user device.

[0176] Step 504: Send a target document synchronization request carrying the first tree structure data to the server.

[0177] In the embodiments of this specification, the first tree structure data mentioned in steps 502 and 504 may be the same as the first tree structure data in step 202, which will not be elaborated further.

[0178] Step 506: Receive the document difference data fed back by the server in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the user device determined by the server from the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0179] In the embodiments of this specification, the document difference data mentioned in step 506 may be the same as the document difference data in step 206, which will not be elaborated further.

[0180] Step 508: Update the target document on the user device using the document difference data.

[0181] In the embodiments of this specification, the user equipment typically needs to determine the leaf node to which the document difference data belongs. Subsequently, the document data corresponding to that leaf node in the target document locally held by the user equipment can be replaced by the document difference data, thereby completing the update of the target document at the user equipment, so that the updated target document at the user equipment is consistent with the target document at the server.

[0182] In addition, the user device also needs to update the hash tree structure data of the target document locally based on the updated target document to ensure consistency between the hash tree of the target document on the server and the user device. In practical applications, the server can also send the latest version information of its hash tree to the user device, so that the user device uses this latest version information as the version information of the locally updated hash tree, which helps ensure the normal operation of the solution.

[0183] Figure 5 The method described above accurately identifies document differences between the target documents on the server and the user device by analyzing the differences in the hash tree structure data of the target documents on the server and the user device. Document synchronization is then achieved by sending these document differences from the target document on the server to the user device. Since it eliminates the need to send the latest version of the complete target document from the server to the user device, it reduces the device resources and time consumed during document synchronization, and also reduces the bandwidth load required for the document synchronization process, thereby improving document synchronization efficiency.

[0184] If the user has previously created the target document using the user device, before step 502: obtaining the first tree structure data of the hash tree of the target document at the user device, it may further include:

[0185] Based on the user's document creation operation, a creation request for the target document is sent to the server; the creation request carries the first document capacity and the number of first leaf nodes of the target document; the server is used to create a hash tree of the target document in response to the creation request, and obtain the initial tree structure data of the hash tree of the target document.

[0186] The server receives the initial tree structure data of the hash tree of the target document. The initial tree structure data includes the lineage information between the nodes in the hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the hash tree. The first document data range is determined based on the first document capacity and the number of the first leaf nodes.

[0187] The above-described embodiments for creating target documents and Figure 2 The implementation examples of creating target documents in the Chinese scheme can be consistent, and will not be elaborated further.

[0188] When the user has previously modified the target document using the user's device. Figure 5 The methods mentioned may also include:

[0189] Based on the document modification operation performed by the user on the target document, the modified document data of the target document is determined; the modified document data is the latest document data corresponding to the target leaf node in the target document that has changed due to the document modification operation.

[0190] Send a target document update request carrying the modified document data to the server.

[0191] In this embodiment of the specification, step 504: sending a target document synchronization request carrying the first tree structure data to the server may specifically include:

[0192] Send a first update status query request for the target document to the server; the first update status query request carries node data of each node of the hash tree of the target document at the user device; or,

[0193] A second update status query request for the target document is sent to the server; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user device.

[0194] After determining that the first node data is inconsistent with the second node data of the root node in the second tree structure data, and that the root node does not belong to a leaf node, a third update status query request for the target document is sent to the server; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user device; the first node is a child node of the root node.

[0195] After determining that the third node data is inconsistent with the fourth node data of the first node in the second tree structure data, and that the first node is not a leaf node, a fourth update status query request for the target document is sent to the server; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user device; the second node is a child node of the first node; or,

[0196] A fifth update status query request for the target document is sent to the server; the fifth update status query request carries the node data of each leaf node of the hash tree of the target document at the user device.

[0197] The above embodiments and Figure 2 In the embodiments of the Chinese scheme, the first update query request to the fifth update query request, the first node data to the fifth node data, the first node, the second node, etc., can all be consistent, which will not be elaborated further.

[0198] Figure 6 The embodiments provided in this specification correspond to Figure 2 and Figure 5 The swimlane flowchart of the target document processing method in [the document / processing framework]. For example... Figure 6 As shown, the target document processing flow can involve various collaborators' user devices and server-side execution entities.

[0199] During the document creation phase, if the user device is the creator's device, it can generate and send a creation request for the target document to the server based on the user's document creation operation. This creation request may carry the first document size and the number of first leaf nodes of the target document. In response to the creation request, the server can create a hash tree for the target document, obtaining the initial tree structure data of the hash tree. This initial tree structure data may include the lineage information between nodes in the hash tree, and the first document data range in the target document corresponding to each of the first number of leaf nodes in the hash tree; the first document data range is determined based on the first document size and the number of first leaf nodes. Subsequently, the server can send the initial tree structure data of the target document's hash tree to the user device, allowing the user device to store the initial tree structure data locally.

[0200] During the document update phase, if the user device is the updater's device, it can generate and send an update request for the target document to the server based on the user's document update operation and the tree structure data of the target document's hash tree stored locally on the device. The update request carries the modified document data corresponding to the target leaf nodes in the target document at the user device that have changed due to the document modification operation. The server can then update the target document and the tree structure data of the target document's hash tree at the server based on the modified document data carried in the update request.

[0201] Furthermore, if the user device is the synchronizing device, when synchronizing a target document, the user device can send the first tree structure data of the target document's hash tree at the user device to the server. The server can determine the changed leaf node by comparing the node data of the first tree structure data with the node data of the same node in the hash tree contained in the second tree structure data at the server, following the order from the root node to the leaf node of the target document's hash tree. Alternatively, it can determine the changed leaf node by comparing the node data of each leaf node in the hash tree contained in the first tree structure data with the node data of each leaf node in the hash tree contained in the second tree structure data at the server.

[0202] Subsequently, the server can also determine the document data corresponding to the changed leaf node in the target document at the server as the document difference data between the target document at the server and the target document at the user device, and send the document difference data in the target document at the server to the user device, so that the user device can use the document difference data to update the target document at the user device and update the tree structure data of the hash tree of the target document, thereby completing the document synchronization.

[0203] Based on the same idea, embodiments of this specification also provide apparatus corresponding to the above methods. Figure 7 The embodiments provided in this specification correspond to Figure 2 A schematic diagram of the structure of a target document processing device. Figure 7 The device in the document can be applied to the server side. The leaf nodes of the hash tree of the target document can be hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document can be a hash value generated based on each child node of that parent node; for example... Figure 7 As shown, the device may include:

[0204] The first acquisition module 702 is used to acquire the first tree structure data of the hash tree of the target document at the user device.

[0205] The first determining module 704 is used to determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0206] The second determining module 706 is used to determine the document difference data between the target document at the server and the target document at the user device based on the difference data between the first tree structure data and the second tree structure data.

[0207] The first sending module 708 is used to send the document difference data in the target document at the server to the user equipment.

[0208] based on Figure 7 The embodiments of this specification also provide some specific implementations of the device, which will be described below.

[0209] Optional, Figure 7 The device may further include:

[0210] The second acquisition module is used to acquire a creation request for the target document; the creation request carries the first document size and the number of first leaf nodes of the target document.

[0211] A creation module is configured to, in response to the creation request, create a hash tree of the target document to obtain initial tree structure data of the hash tree of the target document; the initial tree structure data includes lineage information between nodes in the hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the hash tree; wherein, the first document data range is determined based on the first document capacity and the number of first leaf nodes.

[0212] The second sending module is used to send the initial tree structure data of the hash tree of the target document to the user equipment.

[0213] Optionally, the creation module specifically includes:

[0214] The document data range determination unit is used to determine the first document data range in the target document corresponding to each leaf node in the hash tree based on the first document capacity and the number of the first leaf nodes; wherein, the capacity of the first document data range is the quotient of the first document capacity and the number of the first leaf nodes.

[0215] The first sorting unit is used to sort each leaf node in the hash tree according to the order of the first document data range from front to back, so as to obtain a leaf node sequence;

[0216] The first partitioning unit is used to partition a preset number of adjacent leaf nodes in the leaf node sequence into child nodes at the same parent node, thereby obtaining a parent node sequence; wherein, any leaf node has one parent node.

[0217] A prohibition unit is used to prohibit further parent node partitioning for nodes in the parent node sequence if the number of nodes contained in the parent node sequence is equal to one, so as to obtain the hash tree of the target document;

[0218] The second partitioning unit is used to continue partitioning the nodes in the parent node sequence if the number of nodes in the parent node sequence is greater than one, until the number of nodes in the updated parent node sequence is one, thereby obtaining the hash tree of the target document.

[0219] Optional, Figure 7 The device may further include:

[0220] The expansion request acquisition module is used to acquire expansion requests for the target document; the expansion request carries information for determining the required increase in the second document capacity and the number of second leaf nodes for the target document;

[0221] A first adjustment module is configured to, in response to the expansion request, adjust the hash tree of the target document based on the latest version tree structure data of the hash tree of the target document at the server, to obtain the third tree structure data of the expanded hash tree of the target document; the third tree structure data includes the lineage relationship information between each node in the expanded hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the expanded hash tree, and the second document data range in the target document corresponding to the number of newly added leaf nodes of the second leaf node; the second document data range is determined according to the second document capacity and the number of second leaf nodes.

[0222] The first difference data determination module is used to determine the first tree structure difference data between the third tree structure data and the latest version tree structure data;

[0223] The first instruction sending module is used to send a first target document update instruction carrying the first tree structure difference data to the user equipment.

[0224] Optional, Figure 7 The device may further include:

[0225] A scaling-down request acquisition module is used to acquire a scaling-down request for the target document; the scaling-down request carries information for determining the amount of third document capacity that needs to be reduced for the target document.

[0226] The second adjustment module is used to respond to the scaling-down request by adjusting the hash tree of the target document based on the latest version tree structure data of the hash tree of the target document at the server, to obtain the fourth tree structure data of the scaled-down hash tree of the target document; the fourth tree structure data includes the lineage information between the nodes in the scaled-down hash tree, and the range of the first document data in the target document corresponding to the leaf nodes of the fourth leaf nodes in the scaled-down hash tree; wherein, the number of fourth leaf nodes is the difference between the number of first leaf nodes and the number of third leaf nodes to be reduced based on the third document capacity.

[0227] The second difference data determination module is used to determine the second tree structure difference data between the fourth tree structure data and the latest version tree structure data.

[0228] The second instruction sending module is used to send a second target document update instruction carrying the second tree structure difference data to the user equipment.

[0229] Optional, Figure 7 The device may further include:

[0230] The third acquisition module is used to acquire an update request for the target document sent by the user equipment; the update request carries the modified document data corresponding to the target leaf node in the target document at the user equipment that has changed due to the document modification operation.

[0231] An update module is used to respond to the update request and update the target document and the tree structure data of the hash tree of the target document on the server based on the changed document data.

[0232] Optionally, the update request may also carry information about the previous version of the target document at the user device.

[0233] The update module can be specifically used to: if the version information before the update is consistent with the latest version information of the target document at the server, then in response to the update request, update the target document at the server and the tree structure data of the hash tree of the target document based on the changed document data.

[0234] Optionally, the first determining module may include:

[0235] The first determining unit is configured to compare the node data of the same node in the hash tree contained in the first tree structure data and the second tree structure data, according to the order from the root node to the leaf node of the hash tree of the target document, to determine whether the changed leaf node in the hash tree is consistent; or,

[0236] The second determining unit is used to compare whether the node data of each leaf node in the hash tree contained in the first tree structure data and the second tree structure data are consistent, and to determine the leaf nodes in the hash tree that have changed.

[0237] The second determining module can specifically be used for:

[0238] The document data corresponding to the changed leaf node in the target document at the server is determined as the document difference data between the target document at the server and the target document at the user device.

[0239] Optionally, the first determining unit may specifically include:

[0240] The first judgment subunit is used to determine whether the first node data of the root node in the first tree structure data is consistent with the second node data of the root node in the second tree structure data, and to obtain a first judgment result;

[0241] The second judgment subunit is used to determine whether the third node data of the first node in the first tree structure data is consistent with the fourth node data of the first node in the second tree structure data for any first node among the child nodes of the root node if the first judgment result indicates that the first node data is inconsistent with the second node data, and to obtain the second judgment result.

[0242] The first determining subunit is used to determine that the first node is a leaf node in the hash tree that has changed if the first node belongs to a leaf node and the second determination result indicates that the data of the third node is inconsistent with the data of the fourth node.

[0243] The third judgment subunit is used to determine whether the fifth node data of the second node in the first tree structure data is consistent with the sixth node data of the second node in the second tree structure data for any second node among the child nodes of the first node if the first node is not a leaf node and the second judgment result indicates that the data of the third node is inconsistent with the data of the fourth node, and to obtain the third judgment result.

[0244] The second determining subunit is used to determine that the second node is a leaf node in the hash tree that has changed if the second node belongs to a leaf node and the third determination result indicates that the data of the fifth node is inconsistent with the data of the sixth node.

[0245] Optionally, the first acquisition module 702 may specifically include:

[0246] The first request acquisition unit is configured to acquire a first update status query request for the target document sent by the user equipment; the first update status query request carries node data of each node of the hash tree of the target document at the user equipment; or...

[0247] The second request acquisition unit is used to acquire a second update status query request for the target document sent by the user equipment; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user equipment.

[0248] The third request acquisition unit is used to acquire a third update status query request for the target document sent by the user equipment; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user equipment; the third update status query request is a request sent by the user equipment to the server after determining that the first node data is inconsistent with the second node data and that the root node does not belong to the leaf node.

[0249] The fourth request acquisition unit is used to acquire the fourth update status query request for the target document sent by the user equipment; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user equipment; the fourth update status query request is a request sent by the user equipment to the server after determining that the third node data is inconsistent with the fourth node data and that the first node does not belong to a leaf node.

[0250] Optionally, the second determining unit may specifically include:

[0251] The fourth judgment subunit is used to determine whether the seventh node data of any leaf node contained in the first tree structure data is consistent with the eighth node data of any leaf node contained in the second tree structure data for any leaf node in the hash tree of the target document, and to obtain the fourth judgment result.

[0252] The third determining subunit is used to determine any leaf node as the changed leaf node in the hash tree if the fourth determination result indicates that the data of the seventh node is inconsistent with the data of the eighth node.

[0253] Optionally, the first acquisition module 702 may specifically include:

[0254] The fifth request acquisition unit is used to acquire a fifth update status query request for the target document sent by the user equipment; the fifth update status query request carries node data of each leaf node of the hash tree of the target document at the user equipment.

[0255] Based on the same idea, embodiments of this specification also provide apparatus corresponding to the above methods. Figure 8 The embodiments provided in this specification correspond to Figure 5 A schematic diagram of the structure of a target document processing device. Figure 8 The device in the document can be applied to a user device. The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node. Figure 8 As shown, the device may include:

[0256] The acquisition module 802 is used to acquire the first tree structure data of the hash tree of the target document at the user equipment.

[0257] The sending module 804 is used to send a target document synchronization request carrying the first tree structure data to the server.

[0258] The receiving module 806 is configured to receive document difference data fed back by the server in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the user device determined by the server from within the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0259] The update module 808 is used to update the target document at the user device using the document difference data.

[0260] based on Figure 8 The embodiments of this specification also provide some specific implementations of the device, which will be described below.

[0261] Optional, Figure 8 The transmitting module in the device may include:

[0262] A first sending unit is configured to send a first update status query request for the target document to the server; the first update status query request carries node data of each node of the hash tree of the target document at the user equipment; or...

[0263] The second sending unit is configured to send a second update status query request for the target document to the server; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user equipment.

[0264] The third sending unit is configured to send a third update status query request for the target document to the server after determining that the first node data is inconsistent with the second node data of the root node in the second tree structure data, and that the root node does not belong to a leaf node; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user equipment; the first node is a child node of the root node.

[0265] The fourth sending unit is configured to, after determining that the third node data is inconsistent with the fourth node data of the first node in the second tree structure data, and that the first node is not a leaf node, send a fourth update status query request for the target document to the server; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user equipment; the second node is a child node of the first node; or,

[0266] The fifth sending unit is used to send a fifth update status query request for the target document to the server; the fifth update status query request carries node data of each leaf node of the hash tree of the target document at the user equipment.

[0267] Optional, Figure 8 The device may further include:

[0268] A request sending module is created to send a creation request for the target document to the server based on the user's document creation operation. The creation request carries the first document capacity and the number of first leaf nodes of the target document. The server is used to create a hash tree of the target document in response to the creation request and obtain the initial tree structure data of the hash tree of the target document.

[0269] An initial tree structure data receiving module is used to receive the initial tree structure data of the hash tree of the target document fed back by the server; the initial tree structure data includes the lineage information between each node in the hash tree, and the first document data range in the target document corresponding to the first number of leaf nodes in the hash tree; wherein, the first document data range is determined according to the first document capacity and the first number of leaf nodes.

[0270] Optional, Figure 8 The device may further include:

[0271] The modified document data determination module is used to determine the modified document data of the target document based on the document modification operation performed by the user on the target document; the modified document data is the latest document data corresponding to the target leaf node in the target document that has changed with the document modification operation;

[0272] The update request sending module is used to send a target document update request carrying the changed document data to the server.

[0273] Based on the same idea, this specification also provides devices corresponding to the above methods in its embodiments.

[0274] Figure 9 The embodiments provided in this specification correspond to Figure 2 A schematic diagram of the structure of a target document processing device. For example... Figure 9 As shown, device 900 can be a server-side device. The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document. Any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node. Device 900 may include:

[0275] At least one processor 910; and,

[0276] Memory 930 communicatively connected to the at least one processor; wherein,

[0277] The memory 930 stores instructions 920 that can be executed by the at least one processor 910, the instructions being executed by the at least one processor 910 to enable the at least one processor 910 to:

[0278] Obtain the first tree structure data of the hash tree of the target document at the user device.

[0279] Determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the device.

[0280] Based on the difference data between the first tree structure data and the second tree structure data, document difference data between the target document at the device and the target document at the user device is determined.

[0281] Send the document difference data within the target document at the device to the user device.

[0282] Based on the same idea, this specification also provides devices corresponding to the above methods in its embodiments.

[0283] Figure 10 The embodiments provided in this specification correspond to Figure 3 A schematic diagram of the structure of a target document processing device. For example... Figure 10 As shown, device 1000 can be a user device. The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document. Any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node. Device 1000 may include:

[0284] At least one processor 1010; and,

[0285] Memory 1030 communicatively connected to the at least one processor; wherein,

[0286] The memory 1030 stores instructions 1020 that can be executed by the at least one processor 1010, the instructions being executed by the at least one processor 1010 to enable the at least one processor 1010 to:

[0287] Obtain the first tree structure data of the hash tree of the target document at the device.

[0288] Send a target document synchronization request carrying the first tree structure data to the server.

[0289] The server receives document difference data in response to the target document synchronization request; wherein the document difference data is the difference data between the target document at the server and the target document at the device, determined by the server from the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server.

[0290] The target document at the device is updated using the document difference data.

[0291] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on its differences from other embodiments. In particular, for... Figure 7 and Figure 8 As the device shown is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0292] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using hardware physical modules. For example, a Programmable Logic Device (PLD) (such as a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program a digital system themselves to "integrate" it onto a PLD, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0293] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0294] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0295] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.

[0296] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0297] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0298] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0299] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0300] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0301] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0302] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (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 technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0303] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0304] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0305] This application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0306] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A method for processing a target document, wherein the method is applied on a server, wherein, The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node; the method includes: The system obtains the first tree structure data of the hash tree of the target document at the user device; the target document includes a multi-person collaborative document; the document data range in the target document corresponding to each leaf node in the hash tree is determined based on the first document capacity and the number of first leaf nodes; the first document capacity is the maximum capacity of the target document pre-specified when creating the target document; the number of first leaf nodes is the number of leaf nodes in the hash tree pre-specified when creating the target document; each leaf node uses the hash of a data block as its label; The difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server is determined; the second tree structure data is generated based on the document data of the latest version of the target document; Based on the difference data between the first tree structure data and the second tree structure data, the document difference data between the target document at the server and the target document at the user device is determined; Send the document difference data within the target document from the server to the user device.

2. The method of claim 1, further comprising, before obtaining the first tree structure data of the hash tree of the target document at the user device: Obtain the creation request for the target document; The creation request carries the first document size and the number of first leaf nodes of the target document. In response to the creation request, a hash tree of the target document is created to obtain the initial tree structure data of the hash tree of the target document; The initial tree structure data includes lineage information between nodes in the hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the hash tree; wherein, the first document data range is determined based on the first document capacity and the number of first leaf nodes. Send the initial tree structure data of the hash tree of the target document to the user device.

3. The method as described in claim 2, wherein creating a hash tree for the target document in response to the creation request specifically includes: Based on the first document capacity and the first leaf node number, the range of first document data in the target document corresponding to each leaf node in the hash tree is determined; wherein, the capacity of the first document data range is the quotient of the first document capacity and the first leaf node number. Sort the leaf nodes in the hash tree according to the order of the first document data range from front to back to obtain the leaf node sequence; A predetermined number of adjacent leaf nodes in the leaf node sequence are divided into child nodes at the same parent node to obtain a parent node sequence; wherein, any leaf node has one parent node. If the number of nodes in the parent node sequence is equal to one, then further parent node partitioning is prohibited for the nodes in the parent node sequence, and the hash tree of the target document is obtained. If the number of nodes in the parent node sequence is greater than one, then the nodes in the parent node sequence are further divided into parent nodes until the number of nodes in the updated parent node sequence is one, thus obtaining the hash tree of the target document.

4. The method of claim 2 or 3, further comprising, after creating the hash tree of the target document in response to the creation request: Obtain the expansion request for the target document; The expansion request carries information for determining the required additional second document capacity and the number of second leaf nodes for the target document. In response to the expansion request, based on the latest version tree structure data of the hash tree of the target document at the server, the hash tree of the target document is adjusted to obtain the third tree structure data of the expanded hash tree of the target document. The third tree structure data contains the lineage information between the nodes in the expanded hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the expanded hash tree, and the second document data range in the target document corresponding to the number of newly added leaf nodes of the second leaf node. The second document data range is determined according to the second document capacity and the number of second leaf nodes. Determine the first tree structure difference data between the third tree structure data and the latest version tree structure data; Send a first target document update instruction carrying the first tree structure difference data to the user device.

5. The method of claim 2 or 3, further comprising, after creating the hash tree of the target document in response to the creation request: Obtain a scaling request for the target document; The reduction request carries information for determining the required reduction in the size of a third document for the target document; In response to the scaling-down request, based on the latest version tree structure data of the target document's hash tree at the server, the hash tree of the target document is adjusted to obtain the fourth tree structure data of the scaled-down hash tree of the target document. The fourth tree structure data contains the lineage information between the nodes in the scaled-down hash tree, and the range of the first document data in the target document corresponding to the number of fourth leaf nodes in the scaled-down hash tree. The number of fourth leaf nodes is the difference between the number of first leaf nodes and the number of third leaf nodes to be reduced based on the third document capacity. Determine the second tree structure difference data between the fourth tree structure data and the latest version tree structure data; Send a second target document update instruction carrying the difference data of the second tree structure to the user device.

6. The method of claim 1, further comprising: Obtain the update request for the target document sent by the user equipment; The update request carries the modified document data corresponding to the target leaf node in the target document at the user device that has changed due to the document modification operation; In response to the update request, the target document and the tree structure data of the hash tree of the target document at the server are updated based on the changed document data.

7. The method of claim 6, wherein the update request further carries information about the previous version of the target document at the user equipment; In response to the update request, based on the changed document data, the target document and the tree structure data of the hash tree of the target document at the server are updated, specifically including: If the version information before the update is consistent with the latest version information of the target document on the server, then in response to the update request, the target document and the tree structure data of the hash tree of the target document on the server are updated based on the changed document data.

8. The method of claim 1, wherein determining the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server specifically includes: By comparing the node data of the same node in the hash tree of the target document from the root node to the leaf node in the first tree structure data and the second tree structure data to determine whether they are consistent, the leaf nodes in the hash tree that have changed are identified; or, By comparing the node data of each leaf node in the hash tree contained in the first tree structure data and the second tree structure data to determine whether they are consistent, the leaf nodes in the hash tree that have changed are identified. The step of determining the document difference data between the target document at the server and the target document at the user device based on the difference data between the first tree structure data and the second tree structure data specifically includes: The document data corresponding to the changed leaf node in the target document at the server is determined as the document difference data between the target document at the server and the target document at the user device.

9. The method of claim 8, wherein the step of comparing the node data of the same node in the hash tree contained in the first tree structure data and the second tree structure data to determine the changed leaf node in the hash tree according to the order from the root node to the leaf node of the hash tree of the target document, specifically includes: Determine whether the first node data of the root node in the first tree structure data is consistent with the second node data of the root node in the second tree structure data, and obtain a first determination result; If the first judgment result indicates that the data of the first node is inconsistent with the data of the second node, then for any first node among the child nodes of the root node, it is determined whether the data of the third node of the first node in the first tree structure data is consistent with the data of the fourth node of the first node in the second tree structure data, and a second judgment result is obtained. If the first node is a leaf node, and the second determination result indicates that the data of the third node is inconsistent with the data of the fourth node, then the first node is determined to be a leaf node in the hash tree that has undergone changes.

10. The method of claim 9, wherein determining the changed leaf node in the hash tree by comparing the node data of the same node in the hash tree contained in the first tree structure data and the second tree structure data in order from the root node to the leaf node of the hash tree of the target document, further comprising: If the first node is not a leaf node, and the second judgment result indicates that the data of the third node is inconsistent with the data of the fourth node, then for any second node among the child nodes of the first node, it is determined whether the data of the fifth node of the second node in the first tree structure data is consistent with the data of the sixth node of the second node in the second tree structure data, and a third judgment result is obtained. If the second node is a leaf node, and the third judgment result indicates that the data of the fifth node is inconsistent with the data of the sixth node, then the second node is determined to be a leaf node in the hash tree that has undergone changes.

11. The method of claim 10, wherein obtaining the first tree structure data of the hash tree of the target document at the user device specifically includes: Obtain the first update status query request for the target document sent by the user device; The first update status query request carries node data of each node of the hash tree of the target document at the user device. or, Obtain a second update status query request for the target document sent by the user equipment; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user equipment; Obtain a third update status query request for the target document sent by the user equipment; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user equipment; the third update status query request is a request sent by the user equipment to the server after determining that the first node data is inconsistent with the second node data and that the root node does not belong to a leaf node. Obtain the fourth update status query request for the target document sent by the user equipment; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user equipment; the fourth update status query request is a request sent by the user equipment to the server after determining that the third node data is inconsistent with the fourth node data and that the first node is not a leaf node.

12. The method of claim 8, wherein comparing whether the node data of each leaf node in the hash tree contained in the first tree structure data and the second tree structure data are consistent, and determining the changed leaf node in the hash tree, specifically includes: For any leaf node in the hash tree of the target document, determine whether the seventh node data of the leaf node contained in the first tree structure data is consistent with the eighth node data of the leaf node contained in the second tree structure data, and obtain the fourth determination result. If the fourth determination result indicates that the data of the seventh node is inconsistent with the data of the eighth node, then any leaf node is determined as the leaf node in the hash tree that has changed.

13. The method of claim 12, wherein obtaining the first tree structure data of the hash tree of the target document at the user device specifically includes: Obtain the fifth update status query request for the target document sent by the user equipment; The fifth update query request carries node data of each leaf node of the hash tree of the target document at the user device.

14. A method for processing a target document, the method being applied to a user device, wherein, The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node; the method includes: Obtain the first tree structure data of the hash tree of the target document at the user device; the target document includes multi-person collaborative documents; the document data range in the target document corresponding to each leaf node in the hash tree is determined according to the first document capacity and the number of first leaf nodes; the first document capacity is the maximum capacity of the target document pre-specified when creating the target document; the number of first leaf nodes is the number of leaf nodes of the hash tree pre-specified when creating the target document; each leaf node uses the hash of a data block as its label; Send a target document synchronization request carrying the first tree structure data to the server; The system receives document difference data from the server in response to the target document synchronization request; wherein, the document difference data is determined by the server from within the target document at the server, based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server, and is the difference data between the target document at the server and the target document at the user device; the second tree structure data is generated based on the document data of the latest version of the target document; The target document at the user device is updated using the document difference data.

15. The method of claim 14, further comprising, before obtaining the first tree structure data of the hash tree of the target document at the user equipment: Based on the user's document creation operation, a creation request for the target document is sent to the server; The creation request carries the first document size and the number of first leaf nodes of the target document; The server is used to create a hash tree of the target document in response to the creation request, and obtain the initial tree structure data of the hash tree of the target document; Receive the initial tree structure data of the hash tree of the target document fed back by the server; The initial tree structure data includes lineage information between nodes in the hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the hash tree; wherein the first document data range is determined based on the first document capacity and the number of first leaf nodes.

16. The method of claim 14, further comprising: Based on the document modification operations performed by the user on the target document, determine the changed document data of the target document; The modified document data is the latest document data corresponding to the target leaf node in the target document that has changed due to the document modification operation; Send a target document update request carrying the modified document data to the server.

17. The method of claim 14, wherein sending a target document synchronization request carrying the first tree structure data to the server specifically includes: Send a first update status query request for the target document to the server; The first update status query request carries node data of each node of the hash tree of the target document at the user device. or, A second update status query request for the target document is sent to the server; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user device; After determining that the first node data is inconsistent with the second node data of the root node in the second tree structure data, and that the root node does not belong to a leaf node, a third update status query request for the target document is sent to the server; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user device. The first node is a child node of the root node; After determining that the third node data is inconsistent with the fourth node data of the first node in the second tree structure data, and that the first node is not a leaf node, a fourth update status query request for the target document is sent to the server; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user device; The second node is a child node of the first node; or, A fifth update status query request for the target document is sent to the server; the fifth update status query request carries the node data of each leaf node of the hash tree of the target document at the user device.

18. A target document processing apparatus, wherein the apparatus is applied to a server, wherein, The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node; the apparatus includes: The first acquisition module is used to acquire the first tree structure data of the hash tree of the target document at the user device; the target document includes a multi-person collaborative document; the document data range in the target document corresponding to each leaf node in the hash tree is determined according to the first document capacity and the number of first leaf nodes; the first document capacity is the maximum capacity of the target document pre-specified when creating the target document; the number of first leaf nodes is the number of leaf nodes of the hash tree pre-specified when creating the target document; each leaf node uses the hash of a data block as its label; The first determining module is used to determine the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server. The second determining module is used to determine document difference data between the target document at the server and the target document at the user device based on the difference data between the first tree structure data and the second tree structure data; the second tree structure data is generated based on the document data of the latest version of the target document; The first sending module is used to send the document difference data in the target document at the server to the user device.

19. The apparatus of claim 18, further comprising: The second acquisition module is used to acquire the creation request for the target document; The creation request carries the first document size and the number of first leaf nodes of the target document. A creation module is used to create a hash tree of the target document in response to the creation request, and obtain the initial tree structure data of the hash tree of the target document; The initial tree structure data includes lineage information between nodes in the hash tree, and the first document data range in the target document corresponding to the number of leaf nodes of the first leaf node in the hash tree; wherein, the first document data range is determined based on the first document capacity and the number of first leaf nodes. The second sending module is used to send the initial tree structure data of the hash tree of the target document to the user equipment.

20. The apparatus of claim 18, further comprising: The third acquisition module is used to acquire the update request for the target document sent by the user equipment; The update request carries the modified document data corresponding to the target leaf node in the target document at the user device that has changed due to the document modification operation; An update module is used to respond to the update request and update the target document and the tree structure data of the hash tree of the target document on the server based on the changed document data.

21. The apparatus of claim 18, wherein the first determining module comprises: The first determining unit is configured to compare the node data of the same node in the hash tree contained in the first tree structure data and the second tree structure data, according to the order from the root node to the leaf node of the hash tree of the target document, to determine whether the changed leaf node in the hash tree is consistent; or, The second determining unit is used to compare whether the node data of each leaf node in the hash tree contained in the first tree structure data and the second tree structure data are consistent, and to determine the leaf nodes in the hash tree that have changed. The second determining module is specifically used for: The document data corresponding to the changed leaf node in the target document at the server is determined as the document difference data between the target document at the server and the target document at the user device.

22. A target document processing apparatus, wherein the apparatus is applied to a user equipment, wherein, The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node; the apparatus includes: The acquisition module is used to acquire the first tree structure data of the hash tree of the target document at the user device; the target document includes a multi-person collaborative document; the document data range in the target document corresponding to each leaf node in the hash tree is determined according to the first document capacity and the number of first leaf nodes; the first document capacity is the maximum capacity of the target document pre-specified when creating the target document; the number of first leaf nodes is the number of leaf nodes of the hash tree pre-specified when creating the target document; each leaf node uses the hash of a data block as its label; The sending module is used to send a target document synchronization request carrying the first tree structure data to the server. A receiving module is configured to receive document difference data fed back by the server in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the user device, determined by the server from within the target document at the server based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server; the second tree structure data is generated based on the document data of the latest version of the target document; An update module is used to update the target document on the user device using the document difference data.

23. The apparatus of claim 22, wherein the transmitting module comprises: The first sending unit is configured to send a first update status query request for the target document to the server. The first update status query request carries node data of each node of the hash tree of the target document at the user device. or, The second sending unit is configured to send a second update status query request for the target document to the server; the second update status query request carries the first node data of the root node of the hash tree of the target document at the user equipment. The third sending unit is configured to send a third update status query request for the target document to the server after determining that the first node data is inconsistent with the second node data of the root node in the second tree structure data, and that the root node does not belong to a leaf node; the third update status query request carries the third node data of the first node of the hash tree of the target document at the user equipment. The first node is a child node of the root node; The fourth sending unit is configured to send a fourth update status query request for the target document to the server after determining that the third node data is inconsistent with the fourth node data of the first node in the second tree structure data, and that the first node is not a leaf node; the fourth update status query request carries the fifth node data of the second node of the hash tree of the target document at the user equipment. The second node is a child node of the first node; or, The fifth sending unit is used to send a fifth update status query request for the target document to the server; the fifth update status query request carries node data of each leaf node of the hash tree of the target document at the user equipment.

24. A target document processing device, wherein the device is a server-side device, The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node, including: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: The system obtains the first tree structure data of the hash tree of the target document at the user device; the target document includes a multi-person collaborative document; the document data range in the target document corresponding to each leaf node in the hash tree is determined based on the first document capacity and the number of first leaf nodes; the first document capacity is the maximum capacity of the target document pre-specified when creating the target document; the number of first leaf nodes is the number of leaf nodes in the hash tree pre-specified when creating the target document; each leaf node uses the hash of a data block as its label; The difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the device is determined; the second tree structure data is generated based on the document data of the latest version of the target document; Based on the difference data between the first tree structure data and the second tree structure data, determine the document difference data between the target document at the device and the target document at the user device; Send the document difference data within the target document at the device to the user device.

25. A target document processing device, wherein the device is a user device, The leaf nodes of the hash tree of the target document are hash values ​​generated based on the document data in the target document, and any parent node in the hash tree of the target document is a hash value generated based on each child node of that parent node, including: At least one processor; and, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Obtain the first tree structure data of the hash tree of the target document at the device; the target document includes multi-person collaborative documents; the document data range in the target document corresponding to each leaf node in the hash tree is determined according to the first document capacity and the number of first leaf nodes; the first document capacity is the maximum capacity of the target document pre-specified when creating the target document; the number of first leaf nodes is the number of leaf nodes of the hash tree pre-specified when creating the target document; each leaf node uses the hash of a data block as its label; Send a target document synchronization request carrying the first tree structure data to the server; The system receives document difference data from the server in response to the target document synchronization request; wherein, the document difference data is the difference data between the target document at the server and the target document at the device, determined by the server from within the target document at the server, based on the difference data between the first tree structure data and the second tree structure data of the hash tree of the target document at the server; the second tree structure data is generated based on the document data of the latest version of the target document; The target document at the device is updated using the document difference data.

Citation Information

Patent Citations

  • File online collaborative editing method and editing device

    CN113360457A

  • Quick release method, device and equipment of program file, medium and product

    CN114661304A

  • Multi-file synchronization method based on Hash tree

    CN115221120A

  • File updating device, program and method

    JP2008250903A