CN114218898A - Online collaborative document editing method and device, computer equipment and storage medium - Google Patents

Online collaborative document editing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114218898A
CN114218898A CN202111392010.0A CN202111392010A CN114218898A CN 114218898 A CN114218898 A CN 114218898A CN 202111392010 A CN202111392010 A CN 202111392010A CN 114218898 A CN114218898 A CN 114218898A
Authority
CN
China
Prior art keywords
instruction
instruction set
queue
conflict
editing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111392010.0A
Other languages
Chinese (zh)
Inventor
张中人
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
CCB Finetech Co Ltd
Original Assignee
CCB Finetech Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by CCB Finetech Co Ltd filed Critical CCB Finetech Co Ltd
Priority to CN202111392010.0A priority Critical patent/CN114218898A/en
Publication of CN114218898A publication Critical patent/CN114218898A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30003Arrangements for executing specific machine instructions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • G06Q10/103Workflow collaboration or project management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Strategic Management (AREA)
  • Human Resources & Organizations (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Economics (AREA)
  • Computational Linguistics (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Artificial Intelligence (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • General Business, Economics & Management (AREA)
  • Document Processing Apparatus (AREA)

Abstract

The application relates to an online collaborative document editing method, which comprises the following steps: determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue; if the queue length is more than or equal to 2, reading a first instruction set and a second instruction set according to the insertion sequence of the current instruction queue; if the first instruction set and the second instruction set have instruction conflict, performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set; and executing the first instruction set, taking the new second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.

Description

Online collaborative document editing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of internet technologies, and in particular, to an online collaborative document editing method, apparatus, computer device, and storage medium.
Background
With the development of internet technology, paperless office work is widely popularized. In recent years, document editing is gradually changed from an offline mode to online editing, multi-terminal multi-user real-time browsing and collaborative document editing are supported, a large amount of time for file transmission and version alternation is saved for users, and the office efficiency is greatly improved.
In a traditional implementation manner of online collaborative document editing, when a plurality of terminals edit contents at the same position, the editing change of the latter will cover the former, which may cause the loss of the edited contents of the former. The currently adopted solution is to fragment a target document, and when a user edits the content of a certain area, a locking strategy is adopted, and other users do not allow editing.
Disclosure of Invention
Based on this, it is necessary to provide a method, an apparatus, a computer device, and a storage medium for online collaborative document editing, aiming at a conflict problem during online collaborative document editing.
In a first aspect, the present application provides an online collaborative document editing method, where the method includes:
determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue;
if the queue length is more than or equal to 2, reading a first instruction set and a second instruction set according to the insertion sequence of the current instruction queue;
if the first instruction set and the second instruction set have instruction conflict, performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set;
and executing the first instruction set, taking the new second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.
In one embodiment, the instruction set carries a document version number, and if the document version numbers carried by the first instruction set and the second instruction set are the same, it is determined that an instruction conflict exists between the first instruction set and the second instruction set.
In one embodiment, the method further comprises at least one of:
if the queue length is 1, directly executing an instruction set stored in the current instruction queue;
if the queue length is greater than or equal to 2 and no instruction conflict exists between the first instruction set and the second instruction set, directly executing the first instruction set, taking the second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.
In one embodiment, each instruction of the first set of instructions and the second set of instructions includes a location; the performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set includes:
and if the instructions in the first instruction set can influence the positioning positions of the instructions in the second instruction set, performing instruction conflict conversion on the instructions in the second instruction set which can influence the instructions in the first instruction set to obtain a new second instruction set.
In one embodiment, if an instruction in the first instruction set affects a location of an instruction in the second instruction set, performing instruction conflict conversion on the instruction in the second instruction set that may affect the instruction in the first instruction set to obtain a new second instruction set, includes:
reading a first instruction in the first instruction set and a second instruction in the second instruction set;
and if the positioning position of the first instruction is smaller than that of the second instruction, performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction.
In one embodiment, each instruction in the first instruction set further includes an edit type and a corresponding edit content, and performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction includes:
and updating the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content.
In one embodiment, the editing types include an insertion type and a deletion type, and the updating the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content includes:
if the editing type is an insertion type, increasing the length of the editing content by the positioning position of the second instruction to obtain an updated positioning position of the second instruction;
and if the editing type is a deletion type, reducing the length of the edited content of the positioning position of the second instruction, and obtaining the updated positioning position of the second instruction.
In a second aspect, the present application further provides an online collaborative document editing apparatus, including:
the determining module is used for determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue;
a reading module, configured to read a first instruction set and a second instruction set according to an insertion order of the current instruction queue when the queue length is greater than or equal to 2;
the conflict processing module is used for performing instruction conflict conversion on the second instruction set according to the first instruction set when the first instruction set and the second instruction set have instruction conflicts to obtain a new second instruction set;
and the execution module is used for executing the first instruction set, taking the new second instruction set as the first instruction set, and controlling the determination module to determine the queue length of the current instruction queue again.
In one embodiment, the instruction set carries a document version number, and the conflict processing module is configured to determine that an instruction conflict exists between the first instruction set and the second instruction set when the document version numbers carried by the first instruction set and the second instruction set are the same.
In one embodiment, the reading module is further configured to at least one of:
if the queue length is 1, directly controlling the execution module to execute the instruction set stored in the current instruction queue;
if the queue length is greater than or equal to 2 and no instruction conflict exists between the first instruction set and the second instruction set, controlling the execution module to execute the first instruction set, taking the second instruction set as the first instruction set, and controlling the determining module to determine the queue length of the current instruction queue again.
In one embodiment, each instruction of the first set of instructions and the second set of instructions includes a location;
and the conflict processing module is used for performing instruction conflict conversion on the instructions in the second instruction set which can influence according to the first instruction set when the instructions in the first instruction set can influence the positioning positions of the instructions in the second instruction set, so as to obtain a new second instruction set.
In one embodiment, the conflict processing module is configured to read a first instruction in the first instruction set and a second instruction in the second instruction set, and perform instruction conflict conversion on the second instruction according to the first instruction when a location position of the first instruction is smaller than a location position of the second instruction, to obtain a new second instruction.
In one embodiment, each instruction in the first instruction set further includes an edit type and a corresponding edit content, and the conflict processing module is configured to update the location position of the second instruction according to the edit type of the first instruction and the length of the corresponding edit content.
In one embodiment, the edit type includes an insert type and a delete type;
the conflict processing module is used for increasing the length of the edited content by the positioning position of the second instruction when the editing type is an insertion type to obtain an updated positioning position of the second instruction; and when the editing type is a deletion type, reducing the length of the edited content by the positioning position of the second instruction to obtain the updated positioning position of the second instruction.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor implementing the steps of the method described above when executing the computer program.
In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method described above.
According to the online collaborative document editing method, the instruction sets uploaded by the user terminal are stored into the current instruction queue, whether instruction conflict conversion is needed or not is judged according to the queue length of the current instruction queue, when the queue length is larger than or equal to 2, the two instruction sets are sequentially read to judge whether instruction conflict exists or not, and the instruction conflict conversion is carried out on the next instruction set according to the previous instruction set.
Drawings
FIG. 1 is a diagram of an application environment of a method for online collaborative document editing in one embodiment;
FIG. 2 is a flowchart illustrating a method for online collaborative document editing according to an embodiment;
FIG. 3 is a flowchart illustrating a method for online collaborative document editing in another embodiment;
FIG. 4 is a flowchart illustrating a method for online collaborative document editing in another embodiment;
FIG. 5 is a block diagram showing the construction of an online collaborative document editing apparatus according to an embodiment;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The online collaborative document editing method provided by the embodiment of the application can be applied to the application environment shown in fig. 1, and can simultaneously involve the terminal 102 and the server 104. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104, or may be located on the cloud or other network server. Specifically, the current instruction queue on the server 104 stores instruction sets, the instruction sets are generated after the terminal 102 edits the target document displayed on the terminal 102, the number of the terminals 102 may be two or more, and the instruction sets stored in the current instruction queue may be generated by the same terminal 102 or different terminals 102; the server 104 is further configured to determine a queue length of the current instruction queue; when the queue length is more than or equal to 2, reading a first instruction set and a second instruction set according to the insertion sequence of the current instruction queue; when the first instruction set and the second instruction set have instruction conflict, performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set; and executing the first instruction set, taking the new second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.
The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart car-mounted devices, and the like. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, and the like. The server 104 may be implemented as a stand-alone server or as a server cluster comprised of multiple servers.
In one embodiment, as shown in fig. 2, an online collaborative document editing method is provided, which is described by taking the method as an example applied to the server 104 in fig. 1, and includes the following steps:
step 202: determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue.
The instruction set uploaded by the user terminal is an instruction sequence formed by combining single instructions, the instructions are generated by editing operation of a user on a target document displayed on the terminal, each editing operation corresponds to one instruction, and the target document after the corresponding editing operation is obtained after the corresponding instruction is executed. It can be understood that in the generation process of the instruction set, the instructions in the preset time interval may be generated into the instruction set at regular time according to the preset time interval; or after the operation is stopped for more than the preset time through recognition, generating an instruction set corresponding to the instruction before the operation is stopped.
Specifically, the user terminal uploads the generated instruction set to the server in a wireless or wired communication mode, and the server stores the instruction set into a current instruction queue according to a receiving time sequence after receiving the instruction set to form a current instruction queue corresponding to the target document. It will be appreciated that the server determines the queue length of the current instruction queue, i.e. determines the number of instruction sets stored in the current instruction queue.
Step 204: and if the queue length is more than or equal to 2, reading the first instruction set and the second instruction set according to the insertion sequence of the current instruction queue.
The insertion order of the current instruction queue is the time order of storing the instruction set into the current instruction queue.
Specifically, if the number of instruction sets stored in the current instruction queue is greater than or equal to 2, that is, the queue length is greater than or equal to 2, the first instruction set and the second instruction set in the current instruction queue are read according to the time sequence in which the instruction sets are stored in the current instruction queue, and it can be understood that the first instruction set is executed first and then the second instruction set is executed when the read first instruction set is executed before the second instruction set.
Step 206: and if the first instruction set and the second instruction set have instruction conflict, performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set.
The first instruction set and the second instruction set have instruction conflict, which indicates that the instructions in the first instruction set have influence on the instructions in the second instruction set, and when the second instruction set is directly executed after the first instruction set is executed, a target document obtained after the second instruction set is executed is inconsistent with expectations of users after editing operations. Specifically, when there is an instruction conflict between the first instruction set and the second instruction set, the instruction conflict conversion needs to be performed on the second instruction set according to the first instruction set to obtain a new second instruction set, so as to eliminate the influence on the execution of the second instruction set after the execution of the first instruction set.
In one embodiment, the instruction set carries a document version number, and if the document version numbers carried by the first instruction set and the second instruction set are the same, it is determined that an instruction conflict exists between the first instruction set and the second instruction set.
The document version number corresponds to the updated version condition of the target document, and the contents of the target document corresponding to the same document version number are consistent. The document version number is generated and updated by executing a set of instructions. It is understood that the document version number may be the number of updates, the time of the update, or other representation means recognized by those skilled in the art. For example, in the present embodiment, the document version number is the number of times the target document is updated, and the number of updates is increased by 1, taking an integer from 0.
Specifically, if the document version numbers carried by the two instruction sets are the same, it indicates that the two instruction sets are generated by editing the target document of the same version, that is, an instruction conflict situation may occur. If the document version numbers carried by the two instruction sets are different, the two instruction sets are generated by editing the target documents with different versions, and therefore the instruction conflict situation cannot be caused.
Step 208: the first set of instructions is executed and the new second set of instructions is taken as the first set of instructions and the process returns to step 202.
Specifically, a first instruction set is executed, that is, each instruction in the first instruction set is sequentially executed, so that a target document after editing operation corresponding to each instruction is obtained, and the document version number of the target document is increased by 1.
Further, after the first instruction set is executed, a new second instruction set obtained after instruction collision conversion is performed is stored in the current instruction queue as the first instruction set, then the queue length of the current instruction queue is determined again, if the queue length is still greater than or equal to 2, the new second instruction set and the original third instruction set which are the first instruction set are read, and the step 206 is performed to determine the instruction collision.
According to the online collaborative document editing method, the instruction sets uploaded by the user terminal are stored into the current instruction queue, whether instruction conflict conversion is needed or not is judged according to the queue length of the current instruction queue, when the queue length is larger than or equal to 2, the two instruction sets are sequentially read to judge whether instruction conflict exists or not, and instruction conflict conversion is carried out on the next instruction set according to the previous instruction set.
In one embodiment, after determining the queue length of the current instruction queue in step 202, the method further comprises, according to the result of the queue length:
step 203: and if the queue length is 1, directly executing the instruction set stored in the current instruction queue.
Specifically, a queue length of 1 indicates that only one instruction set is stored in the current instruction queue, and then the method directly enters step 208 without determining whether an instruction conflict exists, executes one instruction set stored in the current instruction queue, and after the execution is completed, returns to step 202 again to determine the queue length of the current instruction queue.
In one embodiment, after determining the queue length of the current instruction queue in step 202, the method further comprises, according to the result of the queue length:
step 205: and if the queue length is more than or equal to 2 and no instruction conflict exists between the first instruction set and the second instruction set, directly executing the first instruction set, taking the second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.
Specifically, if the queue length is greater than or equal to 2, which indicates that the number of instruction sets stored in the current instruction queue is greater than or equal to 2, the first instruction set and the second instruction set are read according to the insertion order of the current instruction queue. If the first instruction set and the second instruction set are judged to have no instruction conflict, the step 208 is directly entered, the first instruction set is executed, after the execution is completed, the second instruction set is taken as the first instruction set, and the step 202 is returned to determine the queue length of the current instruction queue.
In one embodiment, each instruction in the first instruction set and the second instruction set includes a positioning location, and performing instruction conflict conversion on the second instruction set according to the first instruction set in step 206 to obtain a new second instruction set includes:
if the instruction in the first instruction set can affect the positioning position of the instruction in the second instruction set, performing instruction conflict conversion on the instruction in the second instruction set which can affect the instruction in the first instruction set, and obtaining a new second instruction set.
Each instruction in each instruction set comprises a positioning position, and the positioning position represents position information of editing operation corresponding to the instruction, namely the position of a cursor when a user edits a target document through a terminal.
Specifically, the instructions in the first instruction set may affect the positioning positions of the instructions in the second instruction set, which means that, on the basis of an updated target document generated after the instructions in the first instruction set are executed, when the target document is directly executed according to the positioning positions of the instructions in the second instruction set, the target document obtained after the second instruction set is executed may be inconsistent with the expectation of the user after the editing operation. Then, the instructions in the second instruction set that will affect the instruction conflict conversion are required to obtain a new second instruction set, so as to eliminate the effect on the execution of the second instruction set after the execution of the first instruction set.
In one embodiment, as shown in fig. 3, performing instruction conflict conversion on instructions in the second instruction set that may affect according to the first instruction set to obtain a new second instruction set includes:
step 302: a first instruction in the first instruction set and a second instruction in the second instruction set are read.
When the instructions in the second instruction set are subjected to instruction conflict conversion, the instructions are obtained by deduction according to the content of the instructions in the first instruction set. However, the number of the instructions in the first instruction set is not fixed, and may be one instruction or two or more instructions generated according to the editing operation of the user terminal on the target document. When the first instruction set only has one instruction, reading one instruction in the first instruction set; when the first instruction set comprises more than two instructions, all the instructions in the first instruction set need to be traversed, and instruction conflict conversion is carried out on the instructions in the second instruction set which can generate influence. Similarly, the number of instructions in the second instruction set is not fixed, and it is also necessary to traverse all the instructions in the second instruction set to complete the instruction conflict conversion.
Specifically, a first instruction in the first instruction set and a second instruction in the second instruction set are read, where the first instruction needs to traverse all instructions in the first instruction set, and the second instruction needs to traverse all instructions in the second instruction set.
Step 304: and if the positioning position of the first instruction is smaller than that of the second instruction, performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction.
Specifically, when the read positioning position of the first instruction is smaller than the positioning position of the second instruction, the cursor position indicating the editing operation corresponding to the first instruction is located before the cursor position indicating the editing operation corresponding to the second instruction, and the second instruction is executed after the first instruction is executed, which may cause that a target document obtained by executing the positioning position of the second instruction may not conform to an expectation of a user after the editing operation, and an instruction conflict conversion needs to be performed on the second instruction according to the first instruction to obtain a new second instruction. Further, after the step of performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction, returning to step 402 to continue reading the next instruction in the first instruction set for judgment until all instructions in the first instruction set are traversed.
On the contrary, if the positioning position of the first instruction is greater than the positioning position of the second instruction, the cursor position of the editing operation corresponding to the first instruction is after the cursor position of the editing operation corresponding to the second instruction, the second instruction is executed after the first instruction is executed, and the positioning position of the second instruction is not affected, so that instruction conflict conversion does not need to be performed on the second instruction, and the step 302 is returned to continue to read the next instruction in the first instruction set for judgment until all instructions in the first instruction set are traversed.
In one embodiment, each instruction in the first instruction set further includes an edit type and a corresponding edit content, and performing instruction conflict conversion on the second instruction according to the first instruction in step 304 to obtain a new second instruction includes:
and updating the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content.
In one embodiment, as shown in fig. 4, the editing types include an insertion type and a deletion type, and updating the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content includes:
step 402: and if the editing type is an insertion type, increasing the length of the editing content by the positioning position of the second instruction to obtain the updated positioning position of the second instruction.
When the target document is updated according to the instruction set, the target document is updated according to the positioning position, the editing type and the corresponding editing content. Specifically, the positioning location is used to determine a location that needs to be updated; the editing type comprises an insertion type and a deletion type and is used for determining whether the content is inserted or deleted; the edited content is used to determine the actual words that are updated.
Specifically, if the edit type of the first instruction is an insert type, it indicates that after the first instruction is executed, the edit content is added at the location of the first instruction. It can be understood that the positioning position of the second instruction needs to increase the length of the edited content, and the target document obtained by executing the second instruction can be ensured to be consistent with the expectation of the user after the editing operation.
Step 404: and if the editing type is the deletion type, reducing the length of the edited content of the positioning position of the second instruction, and obtaining the updated positioning position of the second instruction.
Specifically, if the edit type of the first instruction is a delete type, it indicates that the edit content is reduced at the location of the first instruction after the first instruction is executed. It can be understood that the location of the second instruction needs to reduce the length of the edited content, and the target document obtained by executing the second instruction can be ensured to be consistent with the expectation of the user after the editing operation.
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is further described in detail below with reference to one specific embodiment. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
In one embodiment, assuming that the content of the original target document is "123456", after the user a performs an editing operation based on the original target document, the generated first instruction set includes a first instruction, and the first instruction includes a positioning position, an editing type, and an editing content. Where the instruction to locate the position is denoted as r (I), I denotes a cursor position in the document, and the instruction to edit type may be denoted as I ('xyz') and D ('xyz') according to the insertion type and the deletion type, and 'xyz' denotes the editing content. For example, the first instruction is R (3) I ('ab'), and the target document that the nail desires to get is '123 ab 456'. Similarly, after the user b performs an editing operation based on the original target document, the generated second instruction set includes a second instruction R (4) I ('b'), and the target document desired by the user b is '1234 b 56'.
Assuming that the first set of instructions arrives in the current instruction queue first, the target document will appear as '123 ab 456' after execution of the first set of instructions. At this time, the second instruction set is reached after being directly executed, and the obtained target document is displayed as '123 abb 456', which is not in accordance with the expectation of the user B, so that the instruction conflict conversion needs to be carried out on the second instruction set.
According to the characteristics of the instructions, after the first instruction set is executed, the positioning position in the second instruction set is affected, and the positioning position for executing the second instruction set is inaccurate. The positioning position i of the second instruction set needs to be converted according to the positioning position i in the first instruction set and the length of the edited content 'xyz'. The principle is described as follows:
for any two sets of instruction sets A and B, assume that the mth position fix R instruction in A is R (i)m) Assume that the nth fix position R in B is designated as R (i)n) Let m be equal to n be equal to 1, and let B be equal to 0.
1. Comparison imAnd inThe size of (2):
if imIs less than inIf the mth instruction is an I instruction, the offset is added to the length of the string parameter of the I instruction;
if imIs less than inIf the mth instruction is a D instruction, subtracting the length of the character string parameter of the D instruction from the offset;
if imGreater than inAnd if so, not processing and entering the next step.
2. And (5) enabling m to be m +1, returning to the first step until all R instructions in A are processed, and enabling i to ben=in-offset。
3. And (3) making m be 1, n be n +1 and offset be 0, returning to the first step until all the R instructions in the B are processed, and obtaining a new instruction set which is the instruction set after the instruction conflict processing is carried out.
Taking the first instruction set and the second instruction set generated by the user a and the user b as an example for explanation, I in the second instruction set can be calculated according to the first instruction set, the instruction R (3) in the first instruction set and the instruction R (4) in the second instruction set are analyzed, and 3<4 can know that the operation position of the first instruction set is before the second instruction set, and because the length of the inserted character string 'ab' is 2, the operation position of the second instruction set should be updated to 4+2 ═ 6, the second instruction set is converted into R (6) I ('b') and the operation text is converted into '123 b4 56', and the conflict is resolved.
It should be understood that, although the steps in the flowcharts related to the embodiments as described above are sequentially displayed as indicated by arrows, the steps are not necessarily performed sequentially as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be rotated or alternated with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the present application further provides an online collaborative document editing apparatus for implementing the online collaborative document editing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the method, so that specific limitations in one or more embodiments of the online collaborative document editing apparatus provided below can be referred to the limitations of the online collaborative document editing method in the foregoing, and details are not described herein again.
In one embodiment, as shown in fig. 5, an online collaborative document editing apparatus is provided, including a determining module 510, a reading module 520, a conflict processing module 530, and an executing module 540, wherein:
the determining module 510 is configured to determine a queue length of a current instruction queue, where the current instruction queue stores instruction sets uploaded by the user terminal, and the queue length of the current instruction queue is the number of instruction sets stored in the current instruction queue.
A reading module 520, configured to read the first instruction set and the second instruction set according to the insertion order of the current instruction queue when the queue length is greater than or equal to 2;
a conflict processing module 530, configured to, when an instruction conflict exists between the first instruction set and the second instruction set, perform instruction conflict conversion on the second instruction set according to the first instruction set, to obtain a new second instruction set;
and the execution module 540 is configured to execute the first instruction set, use the new second instruction set as the first instruction set, and control the determination module to determine the queue length of the current instruction queue again.
In one embodiment, the instruction set carries a document version number, and the conflict processing module 530 is configured to determine that an instruction conflict exists between the first instruction set and the second instruction set when the document version numbers carried by the first instruction set and the second instruction set are the same.
In one embodiment, the fetch module 520 is configured to directly control the execution module 540 to execute the instruction set stored in the current instruction queue when the queue length is 1.
In one embodiment, the reading module 520 is configured to determine whether there is an instruction conflict between the first instruction set and the second instruction set by the control conflict processing module 530 when the queue length is greater than or equal to 2; the control conflict processing module 530 is configured to, when there is no instruction conflict between the first instruction set and the second instruction set, control the execution module 540 to execute the first instruction set, and use the second instruction set as the first instruction set, and the control determining module 510 determines the queue length of the current instruction queue again.
In one embodiment, each of the first set of instructions and the second set of instructions includes a location; the conflict processing module 530 is configured to, when an instruction in the first instruction set affects a positioning position of an instruction in the second instruction set, perform instruction conflict conversion on the instruction in the second instruction set that may affect the instruction in the first instruction set, and obtain a new second instruction set.
In one embodiment, the conflict processing module 530 is configured to read a first instruction in the first instruction set and a second instruction in the second instruction set, and perform instruction conflict conversion on the second instruction according to the first instruction when the location position of the first instruction is smaller than the location position of the second instruction, to obtain a new second instruction.
In one embodiment, each instruction in the first instruction set further includes an edit type and a corresponding edit content, and the conflict processing module 530 is configured to update the location position of the second instruction according to the edit type of the first instruction and the length of the corresponding edit content.
In one embodiment, the edit types include an insert type and a delete type; the conflict processing module 530 is configured to, when the edit type is the insertion type, increase the length of the edited content by the positioning position of the second instruction, and obtain an updated positioning position of the second instruction; and when the editing type is the deleting type, reducing the length of the edited content of the positioning position of the second instruction, and obtaining the updated positioning position of the second instruction.
The modules in the online collaborative document editing apparatus may be wholly or partially implemented by software, hardware, or a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing instruction set data in the current instruction queue. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement an online collaborative document editing method.
Those skilled in the art will appreciate that the architecture shown in fig. 6 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, which includes a memory and a processor, the memory stores a computer program, and the processor implements the steps of the method when executing the computer program:
determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue.
And if the queue length is more than or equal to 2, reading the first instruction set and the second instruction set according to the insertion sequence of the current instruction queue.
And if the first instruction set and the second instruction set have instruction conflict, performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set.
And executing the first instruction set, taking the new second instruction set as the first instruction set, and returning to determine the queue length of the current instruction queue.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and if the queue length is 1, directly executing the instruction set stored in the current instruction queue.
And if the queue length is greater than or equal to 2 and no instruction conflict exists between the first instruction set and the second instruction set, directly executing the first instruction set, taking the second instruction set as the first instruction set, and returning to determine the queue length of the current instruction queue.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
if the instruction in the first instruction set can affect the positioning position of the instruction in the second instruction set, performing instruction conflict conversion on the instruction in the second instruction set which can affect the instruction in the first instruction set, and obtaining a new second instruction set.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and reading a first instruction in the first instruction set and a second instruction in the second instruction set.
And if the positioning position of the first instruction is smaller than that of the second instruction, performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and updating the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
and if the editing type is an insertion type, increasing the length of the editing content by the positioning position of the second instruction to obtain the updated positioning position of the second instruction.
And if the editing type is the deletion type, reducing the length of the edited content of the positioning position of the second instruction, and obtaining the updated positioning position of the second instruction.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the above-mentioned online collaborative document editing method.
It should be noted that, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high-density embedded nonvolatile Memory, resistive Random Access Memory (ReRAM), Magnetic Random Access Memory (MRAM), Ferroelectric Random Access Memory (FRAM), Phase Change Memory (PCM), graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
The technical features of the embodiments described above may be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the embodiments described above are not described, but should be considered as being within the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (16)

1. An online collaborative document editing method, characterized in that the method comprises:
determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue;
if the queue length is more than or equal to 2, reading a first instruction set and a second instruction set according to the insertion sequence of the current instruction queue;
if the first instruction set and the second instruction set have instruction conflict, performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set;
and executing the first instruction set, taking the new second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.
2. The online collaborative document editing method according to claim 1, wherein the instruction set carries a document version number, and if the document version numbers carried by the first instruction set and the second instruction set are the same, it is determined that there is an instruction conflict between the first instruction set and the second instruction set.
3. The online collaborative document editing method of claim 1, further comprising at least one of:
if the queue length is 1, directly executing an instruction set stored in the current instruction queue;
if the queue length is greater than or equal to 2 and no instruction conflict exists between the first instruction set and the second instruction set, directly executing the first instruction set, taking the second instruction set as the first instruction set, and returning to the step of determining the queue length of the current instruction queue.
4. The online collaborative document editing method of claim 1, wherein each of the first set of instructions and the second set of instructions includes a location; the performing instruction conflict conversion on the second instruction set according to the first instruction set to obtain a new second instruction set includes:
and if the instructions in the first instruction set can influence the positioning positions of the instructions in the second instruction set, performing instruction conflict conversion on the instructions in the second instruction set which can influence the instructions in the first instruction set to obtain a new second instruction set.
5. The online collaborative document editing method according to claim 4, wherein if an instruction in the first instruction set affects a positioning position of an instruction in the second instruction set, performing instruction conflict transformation on an instruction in the second instruction set that may affect according to the first instruction set to obtain a new second instruction set, includes:
reading a first instruction in the first instruction set and a second instruction in the second instruction set;
and if the positioning position of the first instruction is smaller than that of the second instruction, performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction.
6. The online collaborative document editing method according to claim 5, wherein each instruction in the first instruction set further includes an editing type and a corresponding editing content, and performing instruction conflict conversion on the second instruction according to the first instruction to obtain a new second instruction includes:
and updating the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content.
7. The online collaborative document editing method according to claim 6, wherein the editing types include an insertion type and a deletion type, and the updating of the positioning position of the second instruction according to the editing type of the first instruction and the length of the corresponding editing content includes:
if the editing type is an insertion type, increasing the length of the editing content by the positioning position of the second instruction to obtain an updated positioning position of the second instruction;
and if the editing type is a deletion type, reducing the length of the edited content of the positioning position of the second instruction, and obtaining the updated positioning position of the second instruction.
8. An online collaborative document editing apparatus, the apparatus comprising:
the determining module is used for determining the queue length of a current instruction queue, wherein the current instruction queue stores instruction sets uploaded by a user terminal, and the queue length of the current instruction queue is the number of the instruction sets stored in the current instruction queue;
a reading module, configured to read a first instruction set and a second instruction set according to an insertion order of the current instruction queue when the queue length is greater than or equal to 2;
the conflict processing module is used for performing instruction conflict conversion on the second instruction set according to the first instruction set when the first instruction set and the second instruction set have instruction conflicts to obtain a new second instruction set;
and the execution module is used for executing the first instruction set, taking the new second instruction set as the first instruction set, and controlling the determination module to determine the queue length of the current instruction queue again.
9. The online collaborative document editing apparatus according to claim 8, wherein the instruction set carries a document version number, and the conflict processing module is configured to determine that there is an instruction conflict between the first instruction set and the second instruction set when the document version numbers carried by the first instruction set and the second instruction set are the same.
10. The online collaborative document editing apparatus of claim 8, wherein the reading module is further configured to at least one of:
if the queue length is 1, directly controlling the execution module to execute the instruction set stored in the current instruction queue;
if the queue length is greater than or equal to 2 and no instruction conflict exists between the first instruction set and the second instruction set, controlling the execution module to execute the first instruction set, taking the second instruction set as the first instruction set, and controlling the determining module to determine the queue length of the current instruction queue again.
11. The online collaborative document editing apparatus according to claim 8, wherein each of the first set of instructions and the second set of instructions includes a positioning location;
and the conflict processing module is used for performing instruction conflict conversion on the instructions in the second instruction set which can influence according to the first instruction set when the instructions in the first instruction set can influence the positioning positions of the instructions in the second instruction set, so as to obtain a new second instruction set.
12. The online collaborative document editing apparatus according to claim 11, wherein the conflict processing module is configured to read a first instruction in the first instruction set and a second instruction in the second instruction set, and perform instruction conflict conversion on the second instruction according to the first instruction when a location position of the first instruction is smaller than a location position of the second instruction, so as to obtain a new second instruction.
13. The online collaborative document editing apparatus according to claim 12, wherein each instruction of the first instruction set further includes an editing type and a corresponding editing content, and the conflict processing module is configured to update the location position of the second instruction according to the editing type of the first instruction and a length of the corresponding editing content.
14. The online collaborative document editing apparatus of claim 13, wherein the editing types include an insertion type and a deletion type;
the conflict processing module is used for increasing the length of the edited content by the positioning position of the second instruction when the editing type is an insertion type to obtain an updated positioning position of the second instruction; and when the editing type is a deletion type, reducing the length of the edited content by the positioning position of the second instruction to obtain the updated positioning position of the second instruction.
15. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
16. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202111392010.0A 2021-11-19 2021-11-19 Online collaborative document editing method and device, computer equipment and storage medium Pending CN114218898A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111392010.0A CN114218898A (en) 2021-11-19 2021-11-19 Online collaborative document editing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111392010.0A CN114218898A (en) 2021-11-19 2021-11-19 Online collaborative document editing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114218898A true CN114218898A (en) 2022-03-22

Family

ID=80697923

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111392010.0A Pending CN114218898A (en) 2021-11-19 2021-11-19 Online collaborative document editing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114218898A (en)

Similar Documents

Publication Publication Date Title
EP3113043B1 (en) Method, device and host for updating metadata stored in columns in distributed file system
CN112650766A (en) Database data operation method, system and server
CN112654995A (en) Tracking content attribution in online collaborative electronic documents
CN112685091A (en) Service request processing method, device, equipment and medium based on big data
CN111737981A (en) Vocabulary error correction method and device, computer equipment and storage medium
CN112559529A (en) Data storage method and device, computer equipment and storage medium
CN113918437A (en) User behavior data analysis method and device, computer equipment and storage medium
CN113312052A (en) Component calling method and device, electronic equipment and storage medium
CN115168499B (en) Database table fragmentation method and device, computer equipment and storage medium
CN114218898A (en) Online collaborative document editing method and device, computer equipment and storage medium
CN111666302A (en) User ranking query method, device, equipment and storage medium
CN115543428A (en) Simulated data generation method and device based on strategy template
CN115270731A (en) Collaborative editing method and device for mixed document
CN114564924A (en) Data insertion method, device, equipment and storage medium
CN110286894B (en) Script generation method, script generation device, computer equipment and storage medium
CN110780850B (en) Requirement case auxiliary generation method and device, computer equipment and storage medium
CN116541454B (en) Event configuration method, device, computer equipment and storage medium
CN109857759A (en) Processing method, device, computer equipment and the storage medium of concurrent data
JP7416832B2 (en) Slide storage method and device
CN115168409B (en) Data query method and device for database sub-tables and computer equipment
US11449548B2 (en) Systems and methods for enriching documents for indexing
CN112286579B (en) Data processing method, device, computer readable storage medium and computer equipment
CN117389989A (en) Data synchronization method, apparatus, computer device, storage medium, and program product
CN113901057A (en) Data playback method and device, computer equipment and storage medium
CN116910115A (en) Group query method, device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination