Data processing method and apparatus
Patent Information
- Application Number
- CN202610929618.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-25
- Publication Date
- 2026-10-02
AI Technical Summary
当操作涉及的数据量较大时,转移过程占用较多系统资源,影响操作的响应速度
[0025]综上所述,本公开提供的数据处理方法及装置,该方法包括:响应于用户的操作指令,根据所述操作指令的指令类型确定推送指针及弹出指针的指向;基于所述推送指针及所述弹出指针的指向,确定与所述操作指令相关的目标事务记录的逻辑归属;基于所述目标事务记录关联的目标操作数据对操作对象执行所述操作指令。与相关技术相比,本公开的方案能够根据操作指令的指令类型确定推送指针及弹出指针的指向,并基于指针指向确定目标事务记录的逻辑归属,使得撤销或重做操作仅涉及事务记录逻辑归属的变更,无需在两个存储栈之间物理转移事务记录及关联的操作数据,减少了操作执行过程中的数据处理量,提高了操作响应速度。
Smart Images

Figure CN122861869A_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data processing technology, and in particular to a data processing method and apparatus. Background Technology
[0002] Undo and redo are frequently used functions in various editing software. In related technologies, undo and redo functions are typically implemented based on a dual-stack architecture. The system maintains two independent stacks, one for storing executed operation data and the other for storing undone operation data. When a user performs an undo or redo operation, the operation data is transferred between the two stacks. When the amount of data involved in the operation is large, the transfer process consumes significant system resources, affecting the operation's response speed. Summary of the Invention
[0003] Based on this, the present disclosure provides a data processing method and apparatus. Its main purpose is to solve the above-mentioned technical problems.
[0004] According to a first aspect of this disclosure, a data processing method is provided, comprising: In response to the user's operation command, the direction of the push pointer and the pop-up pointer is determined according to the command type of the operation command; Based on the directions of the push pointer and the pop-up pointer, the logical attribution of the target transaction record related to the operation instruction is determined; The operation instruction is executed on the operation object based on the target operation data associated with the target transaction record.
[0005] In some embodiments, determining the direction of the push pointer and pop pointer based on the instruction type of the user's operation instruction includes: If the instruction type of the operation instruction is an edit instruction or a redo instruction, it is determined that the push pointer points to the first storage stack and the pop pointer points to the second storage stack. When the instruction type of the operation instruction is a cancel instruction, it is determined that the push pointer points to the second storage stack and the pop pointer points to the first storage stack.
[0006] In some embodiments, executing the operation instruction on the operation object based on the target operation data associated with the target transaction record includes: In response to the editing instruction, the target transaction record and the associated target operation data are stored in the first storage stack currently pointed to by the push pointer; In response to the undo command, the push pointer and the pop pointer are swapped, the logical affiliation of the target transaction record is changed from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer, and the operation object is undone based on the target operation data associated with the target transaction record; the points of the push pointer and the pop pointer are restored. In response to the redo instruction, the logical affiliation of the target transaction record is changed from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer, and a redo is performed on the operation object based on the target operation data associated with the target transaction record.
[0007] In some embodiments, transaction records in each storage stack form a bidirectional circular transaction chain through first forward and backward pointers. The step of storing the target transaction record and the associated target operation data into the first storage stack currently pointed to by the push pointer includes: Memory space is allocated within the first storage stack, and the target transaction record and its associated target operation data are written therein; wherein, the first storage stack and the second storage stack each contain a bidirectional circular memory block chain consisting of multiple memory blocks linked by second forward and backward pointers; the target transaction record and its associated target operation data are stored in contiguous memory space within the same memory block; The target transaction record is appended to the tail of the bidirectional circular transaction chain of the first storage stack, and the first forward and backward pointers in the bidirectional circular transaction chain of the first storage stack are updated.
[0008] In some embodiments, changing the logical affiliation of the target transaction record from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer includes: Remove the target transaction record from the tail of the bidirectional circular transaction chain of the first storage stack and attach it to the tail of the bidirectional circular transaction chain of the second storage stack. The step of changing the logical affiliation of the target transaction record from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer includes: The target transaction record is removed from the tail of the bidirectional circular transaction chain of the second storage stack and attached to the tail of the bidirectional circular transaction chain of the first storage stack.
[0009] In some embodiments, when the target transaction record changes its logical affiliation between the first storage stack and the second storage stack, the physical storage location of the target transaction record and its associated target operation data in the memory block remains unchanged.
[0010] In some embodiments, the method further includes: Determine whether the total number of transaction records in each storage stack exceeds a preset threshold; If the total number of transaction records exceeds the preset threshold, the transaction record at the head of the bidirectional circular transaction chain of the storage stack will be removed. If the limit is not exceeded, the value remains unchanged.
[0011] In some embodiments, after removing the transaction record at the head of a doubly circular transaction chain in a storage stack where the total number of transaction records exceeds the preset threshold, the method further includes: Detect whether there are other active transaction records in the memory block where the transaction record in the header is located; If it does not exist, release all memory space of the memory block containing the transaction record in the header, and remove the memory block containing the transaction record in the header from its doubly circular memory block chain. If it exists, then release the memory space within the memory block occupied by the transaction record in the header and its associated operation data.
[0012] In some embodiments, allocating memory space within the first storage stack and writing the target transaction record and its associated target operation data includes: Determine whether the remaining storage space size of the current memory block used for memory allocation in the bidirectional circular memory block chain of the first storage stack is greater than or equal to the size of the target transaction record and its associated target operation data, and obtain the determination result; If the determination result is yes, then allocate contiguous memory space at the end of the used storage space of the current memory block, and write the target transaction record and its associated target operation data. If the judgment result is negative, a new memory block is generated, and the new memory block is connected to the tail of the bidirectional circular memory block chain of the first storage stack through the second forward and backward pointers. A contiguous memory space is allocated in the new memory block, and the target transaction record and its associated target operation data are written.
[0013] According to a second aspect of this disclosure, a data processing apparatus is provided, comprising: The first determining unit is used to respond to the user's operation command and determine the direction of the push pointer and the pop-up pointer according to the command type of the operation command; The second determining unit is used to determine the logical attribution of the target transaction record related to the operation instruction based on the direction of the push pointer and the pop-up pointer. An execution unit is used to execute the operation instructions on the operation object based on the target operation data associated with the target transaction record.
[0014] In some embodiments, the first determining unit includes: The first determining module is used to determine, when the instruction type of the operation instruction is an edit instruction or a redo instruction, that the push pointer points to the first storage stack and the pop pointer points to the second storage stack. The second determining module is used to determine, when the instruction type of the operation instruction is a cancel instruction, that the push pointer points to the second storage stack and the pop pointer points to the first storage stack.
[0015] In some embodiments, the execution unit includes: The first execution module is used to respond to the editing instruction by storing the target transaction record and the associated target operation data into the first storage stack currently pointed to by the push pointer; The second execution module is configured to, in response to the undo command, swap the pointers of the push pointer and the pop pointer, change the logical affiliation of the target transaction record from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer, and perform undo on the operation object based on the target operation data associated with the target transaction record; and restore the pointers of the push pointer and the pop pointer. The third execution module is used to respond to the redo instruction by changing the logical affiliation of the target transaction record from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer, and performing a redo on the operation object based on the target operation data associated with the target transaction record.
[0016] In some embodiments, transaction records in each storage stack form a bidirectional circular transaction chain through first forward and backward pointers, and the first execution module is further configured to: Memory space is allocated within the first storage stack, and the target transaction record and its associated target operation data are written therein; wherein, the first storage stack and the second storage stack each contain a bidirectional circular memory block chain consisting of multiple memory blocks linked by second forward and backward pointers; the target transaction record and its associated target operation data are stored in contiguous memory space within the same memory block; The target transaction record is appended to the tail of the bidirectional circular transaction chain of the first storage stack, and the first forward and backward pointers in the bidirectional circular transaction chain of the first storage stack are updated.
[0017] In some embodiments, the second execution module is further configured to: Remove the target transaction record from the tail of the bidirectional circular transaction chain of the first storage stack and attach it to the tail of the bidirectional circular transaction chain of the second storage stack. The third execution module is also used for: The target transaction record is removed from the tail of the bidirectional circular transaction chain of the second storage stack and attached to the tail of the bidirectional circular transaction chain of the first storage stack.
[0018] In some embodiments, when the target transaction record changes its logical affiliation between the first storage stack and the second storage stack, the physical storage location of the target transaction record and its associated target operation data in the memory block remains unchanged.
[0019] In some embodiments, the device is further configured to: Determine whether the total number of transaction records in each storage stack exceeds a preset threshold; If the total number of transaction records exceeds the preset threshold, the transaction record at the head of the bidirectional circular transaction chain of the storage stack will be removed. If the limit is not exceeded, the value remains unchanged.
[0020] In some embodiments, after removing the transaction record at the head of a doubly circular transaction chain in a storage stack where the total number of transaction records exceeds the preset threshold, the apparatus is further configured to: Detect whether there are other active transaction records in the memory block where the transaction record in the header is located; If it does not exist, release all memory space of the memory block containing the transaction record in the header, and remove the memory block containing the transaction record in the header from its doubly circular memory block chain. If it exists, then release the memory space within the memory block occupied by the transaction record in the header and its associated operation data.
[0021] In some embodiments, the first execution module is further configured to: Determine whether the remaining storage space size of the current memory block used for memory allocation in the bidirectional circular memory block chain of the first storage stack is greater than or equal to the size of the target transaction record and its associated target operation data, and obtain the determination result; If the determination result is yes, then allocate contiguous memory space at the end of the used storage space of the current memory block, and write the target transaction record and its associated target operation data. If the judgment result is negative, a new memory block is generated, and the new memory block is connected to the tail of the bidirectional circular memory block chain of the first storage stack through the second forward and backward pointers. A contiguous memory space is allocated in the new memory block, and the target transaction record and its associated target operation data are written.
[0022] According to a third aspect of this disclosure, an electronic device is provided, comprising: 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 to enable the at least one processor to perform the method described in the first aspect above.
[0023] According to a fourth aspect of this disclosure, a non-transitory computer-readable storage medium is provided storing computer instructions, wherein the computer instructions are configured to cause the computer to perform the method described in the first aspect above.
[0024] According to a fifth aspect of this disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the method described in the first aspect above.
[0025] In summary, the data processing method and apparatus provided in this disclosure include: responding to a user's operation instruction, determining the directions of a push pointer and a pop pointer based on the instruction type of the operation instruction; determining the logical ownership of a target transaction record related to the operation instruction based on the directions of the push pointer and the pop pointer; and executing the operation instruction on the operation object based on the target operation data associated with the target transaction record. Compared with related technologies, the solution of this disclosure can determine the directions of the push pointer and the pop pointer based on the instruction type of the operation instruction, and determine the logical ownership of the target transaction record based on the pointer directions. This makes undo or redo operations only involve changes in the logical ownership of the transaction record, without the need for physical transfer of the transaction record and associated operation data between two storage stacks, reducing the amount of data processing during operation execution and improving operation response speed.
[0026] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this application, nor is it intended to limit the scope of this application. Other features of this application will become readily apparent from the following description. Attached Figure Description
[0027] The accompanying drawings are provided to better understand this solution and do not constitute a limitation of this disclosure. Wherein: Figure 1 This is a schematic flowchart of a data processing method provided in an embodiment of the present disclosure; Figure 2 A schematic diagram illustrating the workflow of a recovery processing logic provided in an embodiment of this disclosure; Figure 3 This is a schematic diagram illustrating the relationship between a transaction chain and a memory block, provided as an embodiment of this disclosure. Figure 4This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of the present disclosure; Figure 5 This is a schematic diagram of another data processing apparatus provided in an embodiment of the present disclosure; Figure 6 This is a schematic block diagram of an example electronic device provided in an embodiment of this disclosure. Detailed Implementation
[0028] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.
[0029] The data processing method and apparatus of this disclosure are described below with reference to the accompanying drawings.
[0030] Figure 1 This is a schematic flowchart of a data processing method provided in an embodiment of the present disclosure.
[0031] like Figure 1 As shown, the method includes steps 101-103.
[0032] Step 101: In response to the user's operation command, determine the direction of the push pointer and the pop-up pointer according to the command type of the operation command.
[0033] In some embodiments, the push pointer and pop pointer are two predefined pointer variables. The push pointer indicates the target storage stack for the currently stored operation record, and the pop pointer indicates the source storage stack for the currently retrieved operation record. The direction of the push and pop pointers determines the direction of the change of ownership of transaction records between storage stacks. For example, in the initial state, the push pointer may point to the first storage stack, and the pop pointer may point to the second storage stack. In this case, newly generated transaction records are stored in the first storage stack, and retrieved transaction records come from the second storage stack.
[0034] When a user's operation command arrives, the system identifies the command type, which distinguishes whether the user intends to perform an undo, redo, or other operation. Based on the command type, the system adjusts the push and pop pointers to match their positions with the data flow direction required by the operation command. The methods for determining the pointers can include, but are not limited to, maintaining the current pointers, swapping the pointers, or setting one pointer to a specific memory stack. It should be noted that the methods for determining the push and pop pointers are not limited to the examples above and can be flexibly adjusted according to the system's preset mapping relationships or configuration parameters in practical applications.
[0035] Using the above method, when a user operation instruction is received, the push pointer and pop pointer are dynamically determined according to the instruction type, so that the pointer points can accurately reflect the data flow direction required by the current operation, providing a basis for the logical ownership judgment of subsequent transaction records.
[0036] Step 102: Based on the directions of the push pointer and the pop-up pointer, determine the logical affiliation of the target transaction record related to the operation instruction.
[0037] In some embodiments, a transaction record is a logical unit for managing a set of operational data. Each transaction record has a logical affiliation, indicating which storage stack the transaction record is currently managed by. The target transaction record is the transaction record associated with the current operation instruction. Once the push and pop pointers are determined, the system can determine that the target transaction record should be moved from the storage stack pointed to by the pop pointer to the storage stack pointed to by the push pointer. Determining the logical affiliation means clarifying that the management relationship of the target transaction record will change between the two storage stacks. This determination process does not involve the physical transfer of the transaction record itself and its associated operational data between the two storage stacks. A storage stack is a data storage structure organized according to access rules, used to store transaction records and operational data. It should be noted that the specific access rules of the storage stack include, but are not limited to, the last-in-first-out rule, and other access orders can also be adopted according to actual needs.
[0038] By using the above method, the logical ownership of the target transaction record is determined based on the pointer, and the execution of the operation instruction is transformed into a decision to change the logical ownership. This makes it possible to perform undo and redo operations without physically transferring transaction records and operation data between two storage stacks.
[0039] Step 103: Execute the operation instruction on the operation object based on the target operation data associated with the target transaction record.
[0040] In some embodiments, after the logical direction of the change required by the operation instruction is determined, the system performs state restoration on the operation object corresponding to the operation instruction based on the target operation data associated with the target transaction record. The target operation data is the data recorded in the target transaction record that describes the state change of the operation object. The operation object is the entity acted upon by the user operation, such as, but not limited to, graphic elements in a graphical editing interface, character paragraphs in a text editing interface, and cell ranges in a table processing interface.
[0041] The specific method of state restoration varies depending on the type of operation instruction, and may include, but is not limited to, restoring the state of the operation object to its state before the operation, restoring the state of the operation object to its state after the operation, or updating the state of the operation object to the target state described by the operation data. It should be noted that the specific execution method of state restoration may include, but is not limited to, calling the restoration interface provided by the operation object itself, executing the reverse operation sequence recorded in the operation data, or replacing the state data of the operation object with historical state data stored in the operation data. This disclosure does not specifically limit this method.
[0042] Using the above method, based on the determined logical ownership change direction and target operation data, the state restoration corresponding to the operation instruction is performed on the operation object, so that operations such as undo and redo can be completed without physically moving transaction records and operation data.
[0043] In summary, according to the data processing method provided in the embodiments of this disclosure, the method can determine the direction of the push pointer and the pop pointer according to the instruction type of the operation instruction, and determine the logical ownership of the target transaction record based on the pointer direction, so that the undo or redo operation only involves the change of the logical ownership of the transaction record, without the need to physically transfer the transaction record and associated operation data between two storage stacks, thereby reducing the amount of data processing during the operation execution process and improving the operation response speed.
[0044] Optionally, based on any of the above embodiments or optional methods, the step of determining the direction of the push pointer and pop pointer according to the instruction type of the operation instruction in response to the user's operation instruction includes: If the instruction type of the operation instruction is an edit instruction or a redo instruction, it is determined that the push pointer points to the first storage stack and the pop pointer points to the second storage stack. When the instruction type of the operation instruction is a cancel instruction, it is determined that the push pointer points to the second storage stack and the pop pointer points to the first storage stack.
[0045] In some embodiments, the direction of the push pointer and the pop pointer is determined by the instruction type of the operation command. The instruction type is used to distinguish the user's current operation intent, such as an edit operation, an undo operation, or a redo operation.
[0046] The first storage stack and the second storage stack are two independent storage areas. The first storage stack is used to receive newly stored transaction records in the context of edit and redo operations, while the second storage stack is used to receive transaction records whose logical ownership has been changed in the context of undo operations.
[0047] When the operation instruction is an edit instruction or a redo instruction, the push pointer is set to point to the first memory stack, and the pop pointer is set to point to the second memory stack. An edit instruction is an instruction generated by the user performing a new operation, such as adding a component, deleting a connection, or modifying an attribute value in the schematic editing interface.
[0048] When a user performs an edit operation, the system generates a corresponding transaction record and operation data. This transaction record needs to be stored in the first storage stack, so the push pointer points to the first storage stack. A redo instruction is an instruction from the user to re-execute an undone operation. When a user performs a redo operation, the system needs to move the previously undone transaction record, which was temporarily stored in the second storage stack, back to the first storage stack. Therefore, the pop pointer points to the second storage stack to retrieve the transaction record, and the push pointer points to the first storage stack to receive the transaction record.
[0049] When the operation instruction is a cancel instruction, the push pointer is set to point to the second storage stack, and the pop pointer is set to point to the first storage stack. A cancel instruction is an instruction from the user to roll back an already executed operation. When a user executes a cancel operation, the system needs to retrieve the latest transaction record originally stored in the first storage stack. After the execution state is restored, this transaction record is temporarily moved to the second storage stack for possible re-execution later. Therefore, the pop pointer points to the first storage stack to retrieve the transaction record to be canceled, and the push pointer points to the second storage stack to receive the transaction record.
[0050] It should be noted that the determination of the pointer's location can be achieved in ways including but not limited to the following: pre-establishing a mapping relationship between instruction types and pointer configurations, and determining the respective locations of the push pointer and pop pointer by querying this mapping relationship when an operation instruction arrives; or executing the corresponding pointer decision logic branch according to the instruction type, specifying the locations of the push pointer and pop pointer in each branch. The above mapping relationship or decision logic can be a preset fixed rule, or it can be set through configuration files or parameters according to the actual application scenario. This disclosure does not specifically limit this.
[0051] By using the above method, the push pointer and pop pointer are clearly distinguished in different operation scenarios according to the instruction type, so that the edit instruction and redo instruction share the same pointer pointing state, while the undo instruction corresponds to a different pointer pointing state, thus providing a clear basis for determining the logical ownership of subsequent transaction records.
[0052] Optionally, based on any of the above embodiments or optional methods, the step of executing the operation instruction on the operation object based on the target operation data associated with the target transaction record includes: In response to the editing instruction, the target transaction record and the associated target operation data are stored in the first storage stack currently pointed to by the push pointer; In response to the undo command, the push pointer and the pop pointer are swapped, the logical affiliation of the target transaction record is changed from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer, and the operation object is undone based on the target operation data associated with the target transaction record; the points of the push pointer and the pop pointer are restored. In response to the redo instruction, the logical affiliation of the target transaction record is changed from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer, and a redo is performed on the operation object based on the target operation data associated with the target transaction record.
[0053] In some embodiments, when the operation instruction is an edit instruction, the system stores the target transaction record and associated target operation data into the first storage stack currently pointed to by the push pointer. Edit instructions correspond to the user performing a new operation, such as moving a component, adding a connection, or modifying an attribute parameter in the schematic editing interface.
[0054] When the user completes the above operations, the system generates a target transaction record corresponding to the operation. This record contains the operation type and operation count. Simultaneously, the system generates target operation data associated with this transaction record, which records the state information of the operation object before and after the operation. Since the current operation is an editing scenario, the push pointer points to the first storage stack. The system then stores the generated target transaction record and target operation data together in the first storage stack, completing the data recording for the editing operation.
[0055] When the operation instruction is an undo instruction, the system first swaps the pointers of the push and pop pointers, making the push pointer point to the second storage stack and the pop pointer point to the first storage stack. Swapping pointer pointers means exchanging the storage stacks currently pointed to by the two pointer variables. This swap does not involve the physical transfer of any data in the storage stacks; it only changes the target address value stored in the pointer variables. After the pointer swap is complete, the pop pointer points to the first storage stack, and the push pointer points to the second storage stack. The system then calls a unified recovery logic to execute the undo operation. The recovery logic is a set of procedures shared by undo and redo. This procedure is independent of the specific pointer pointers and only performs operations based on the storage stacks currently pointed to by the push and pop pointers. The recovery logic first retrieves the target transaction record from the first storage stack pointed to by the pop pointer. The target transaction record contains the operation count of the transaction. Based on the operation count, the system retrieves each target operation data associated with the target transaction record one by one. For each target operation data, the system obtains the type identifier of the operation object, searches for the corresponding state recovery function from the pre-configured mapping relationship set based on the type identifier, and calls the state recovery function to perform state recovery on the operation object, such as restoring the coordinates of the moved component to the coordinates before the move.
[0056] Once all operation data within the target transaction record has been processed, the system stores the target transaction record into the second storage stack pointed to by the push pointer, completing the logical change of the target transaction record's ownership from the first storage stack to the second storage stack. After the recovery processing logic is executed, the system restores the pointers to their original positions by swapping them again, so that the push pointer points back to the first storage stack and the pop pointer points back to the second storage stack, restoring the pointers to their default state.
[0057] When the operation instruction is a redo instruction, the system directly executes the processing flow under the current pointer state. The current pointer state is the default state, i.e., the push pointer points to the first storage stack, and the pop pointer points to the second storage stack. The recovery processing logic retrieves the target transaction record from the second storage stack pointed to by the pop pointer, retrieves the target operation data one by one, and calls the corresponding state recovery function to restore the state of the operation object to the state before the operation was undone. After processing, the target transaction record is stored in the first storage stack pointed to by the push pointer, completing the logical change of the target transaction record's ownership from the second storage stack to the first storage stack. Since the redo instruction calls the same recovery processing logic as the undone instruction, the system does not need to write a separate processing program for the redo instruction.
[0058] To clearly illustrate the embodiments of this disclosure, Figure 2 This is a schematic diagram of the workflow of a recovery processing logic provided in an embodiment of the present disclosure, as shown below. Figure 2As shown, the workflow of the recovery processing logic includes the following: The process checks if a transaction record exists in the stack currently pointed to by the pop pointer. If not, the process ends; if it exists, the target transaction record is retrieved from the stack currently pointed to by the pop pointer. For example, when the operation instruction is an undo instruction, the pointers have already been swapped, and the pop pointer points to the first stack. In this case, the target transaction record is retrieved from the first stack.
[0059] Determine if the operation count in the target transaction record is greater than 0. If it is not greater than 0, push the target transaction record onto the storage stack currently pointed to by the push pointer; if it is greater than 0, retrieve the target operation data associated with the target transaction record one by one.
[0060] For the retrieved target operation data, obtain the type identifier of the operation object, find the corresponding state recovery function from the pre-configured mapping relationship set based on the type identifier, and call the state recovery function to perform state recovery on the operation object.
[0061] Once all target operation data associated with the target transaction record has been processed, the target transaction record is pushed onto the storage stack currently pointed to by the push pointer. For example, when the operation instruction is an undo instruction, the push pointer points to the second storage stack, and the target transaction record is stored in the second storage stack. For redo instructions, the above steps of the recovery processing logic are completely the same, the only difference being that the target transaction record is retrieved from the second storage stack pointed to by the pop pointer and stored in the first storage stack pointed to by the push pointer.
[0062] It should be noted that the mapping relationship between type identifiers and state recovery functions can be implemented in ways including but not limited to the following: a mapping table is pre-built, and the pointers of state recovery functions corresponding to each type of operation object are stored in the mapping table. When a function needs to be called, it is indexed by the type identifier. The specific implementation of the state recovery function depends on the characteristics of the operation object itself. The operation object can provide a unified recovery interface for the system to call. This disclosure does not specifically limit this aspect.
[0063] In this way, the data processing flow of edit, undo, and redo instructions can be clearly distinguished. Undo and redo are both implemented through logical ownership changes, without the need to physically transfer data between storage stacks. At the same time, undo and redo share the same processing mechanism, reducing code redundancy.
[0064] Optionally, based on any of the above embodiments or optional methods, the transaction records in each storage stack form a bidirectional circular transaction chain through first forward and backward pointers, and storing the target transaction record and the associated target operation data into the first storage stack currently pointed to by the push pointer includes: Memory space is allocated within the first storage stack, and the target transaction record and its associated target operation data are written therein; wherein, the first storage stack and the second storage stack each contain a bidirectional circular memory block chain consisting of multiple memory blocks linked by second forward and backward pointers; the target transaction record and its associated target operation data are stored in contiguous memory space within the same memory block; The target transaction record is appended to the tail of the bidirectional circular transaction chain of the first storage stack, and the first forward and backward pointers in the bidirectional circular transaction chain of the first storage stack are updated.
[0065] In some embodiments, transaction records within each storage stack form a doubly linked circular transaction chain using first forward and backward pointers. This chain links all transaction records in the storage stack in the order they were stored, achieving ordered management of transaction records. The first forward and backward pointers include a pointer to the previous transaction record and a pointer to the next transaction record. Each transaction record node in the doubly linked circular transaction chain is connected to its adjacent nodes via the first forward and backward pointers, forming a circular linked list structure. The transaction record node closest to the current time is located at the tail, and the transaction record node farthest from the current time is located at the head.
[0066] When the operation instruction is an edit instruction that requires storing the target transaction record and associated target operation data into the first storage stack currently pointed to by the push pointer, the system first allocates memory space within the first storage stack. The first and second storage stacks each contain a doubly linked circular memory block chain consisting of multiple memory blocks linked by second forward and backward pointers. Each memory block is a contiguous physical memory region, and memory blocks are linked together by the second forward and backward pointers, which include pointers to the previous memory block and pointers to the next memory block. All memory blocks are connected end-to-end to form a circular structure. In the doubly linked circular memory block chain, the most recently created or currently being allocated memory block is called the current memory block.
[0067] The system allocates a contiguous block of memory within the current memory block of the doubly linked circular memory block, starting from the end of the used storage space. The target transaction record and associated target operation data are then written into this contiguous memory space. The target transaction record contains information such as transaction identifier, operation count, and status flags. The target operation data includes the identifier of the operation object, the operation type, and the state data of the operation object before and after the operation. The target transaction record and target operation data are stored in contiguous memory space within the same memory block, and are physically adjacent to each other.
[0068] After writing the target transaction record and target operation data into the memory block, the system appends the target transaction record to the tail of the doubly linked circular transaction chain in the first storage stack. Appending to the tail means inserting the newly written transaction record, as the closest transaction record node to the current time in the transaction chain, into the tail position of the transaction chain. During appending, the system updates the first forward and backward pointers of the target transaction record, making its forward pointer point to the original tail transaction record and its backward pointer point to the head transaction record; simultaneously, it updates the backward pointer of the original tail transaction record and the forward pointer of the head transaction record, making them both point to the newly appended target transaction record, thus maintaining the head-to-tail connection structure of the doubly linked circular transaction chain. By updating the first forward and backward pointers, the target transaction record is included in the transaction chain management scope of the first storage stack, and its logical affiliation is formally established as the first storage stack.
[0069] To clearly illustrate the above embodiments, Figure 3 This is a schematic diagram illustrating the relationship between a transaction chain and a memory block, as provided in an embodiment of this disclosure. Figure 3 As shown, a memory block stores two transaction records, transaction record T1 and transaction record T2. Transaction record T2 is the most recent transaction record and is located at the tail of the doubly linked circular transaction chain. Transaction records T1 and T2 are each associated with operation data, stored in contiguous memory spaces within their respective memory blocks. Transaction records T1 and T2 are connected by a first set of forward and backward pointers, including a forward pointer (prev) and a backward pointer (next), forming a doubly linked circular transaction chain. Each transaction record also includes information such as a transaction identifier (ID) and operation count (ops). Furthermore, the storage stack maintains a pointer (last_transaction_) pointing to the transaction record at the tail of the doubly linked circular transaction chain. This pointer points to transaction record T2, used for quickly locating the latest transaction record.
[0070] It should be noted that the creation and management of memory blocks can take the following forms, including but not limited to: pre-allocating one or more memory blocks during storage stack initialization, and dynamically requesting new memory blocks when storage space is insufficient. The initial size of the memory blocks can be configured according to the actual application scenario. This disclosure does not impose specific limitations on the allocation and release management methods of memory blocks.
[0071] Using the above method, transaction records are organized in an orderly manner through a bidirectional circular transaction chain. Transaction records and operation data are stored together in the contiguous space of the same memory block, reducing the number of memory allocations. At the same time, the transaction chain structure facilitates fast insertion and removal operations at the tail and head.
[0072] Optionally, based on any of the above embodiments or optional methods, changing the logical affiliation of the target transaction record from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer includes: The target transaction record is removed from the tail of the bidirectional circular transaction chain of the first storage stack and attached to the tail of the bidirectional circular transaction chain of the second storage stack.
[0073] In some embodiments, the change of logical ownership is achieved through node removal and attachment operations on a bidirectional circular transaction chain. This operation does not involve the transfer of the target transaction record and its associated target operation data in physical storage space. When the operation instruction is a reversal instruction, the push pointer has been swapped to point to the second storage stack, and the pop pointer has been swapped to point to the first storage stack. At this time, it is necessary to change the target transaction record from the first storage stack to the second storage stack for management. The system first locates the tail of the bidirectional circular transaction chain in the first storage stack. The tail transaction record is the transaction record most recent to the current time, which is the target transaction record to be processed in this reversal operation. The system modifies the back pointer of the preceding transaction record and the front pointer of the following transaction record of the target transaction record to directly connect the adjacent transaction records before and after the target transaction record, thereby removing the target transaction record from the bidirectional circular transaction chain in the first storage stack. After the removal operation is completed, the tail of the bidirectional circular transaction chain in the first storage stack is changed to the transaction record preceding the original tail transaction record. It should be noted that the removal operation only changes the first before-after pointer connection relationship between transaction record nodes on the transaction chain; the physical storage location of the target transaction record itself and its associated target operation data in the memory block remains unchanged.
[0074] After removing the target transaction record from the doubly linked circular transaction chain of the first storage stack, the system attaches the target transaction record to the tail of the doubly linked circular transaction chain of the second storage stack. Attaching means adding the target transaction record as a new tail node to the doubly linked circular transaction chain of the second storage stack. The system first sets the front pointer of the target transaction record to the original tail transaction record in the second storage stack transaction chain and sets the back pointer of the target transaction record to the head transaction record in the second storage stack transaction chain; then, it updates the back pointer of the original tail transaction record and the front pointer of the original head transaction record in the second storage stack transaction chain, making them both point to the newly attached target transaction record. After the attachment is complete, the target transaction record becomes the new tail of the doubly linked circular transaction chain of the second storage stack, and its logical affiliation officially changes to the second storage stack.
[0075] The step of changing the logical affiliation of the target transaction record from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer includes: The target transaction record is removed from the tail of the bidirectional circular transaction chain of the second storage stack and attached to the tail of the bidirectional circular transaction chain of the first storage stack.
[0076] In some embodiments, when the operation instruction is a redo instruction, the push pointer points to the first storage stack, and the pop pointer points to the second storage stack. At this point, the target transaction record needs to be transferred from the second storage stack to the first storage stack for management. Following the same removal and attachment operation process as the undo instruction, the system first removes the target transaction record from the tail of the bidirectional circular transaction chain in the second storage stack. This means directly connecting the adjacent transaction records before and after the tail transaction record using the first forward and backward pointers, thus removing the target transaction record from the transaction chain management of the second storage stack. After the removal operation is completed, the tail of the bidirectional circular transaction chain in the second storage stack becomes the transaction record preceding the original tail transaction record. Subsequently, the system attaches the target transaction record to the tail of the bidirectional circular transaction chain in the first storage stack. By updating the backward pointer of the original tail transaction record and the forward pointer of the head transaction record in the first storage stack transaction chain, the target transaction record becomes the new tail of the first storage stack transaction chain, completing the change of the target transaction record's logical affiliation from the second storage stack to the first storage stack. Similar to the undo operation, the entire removal and attachment process of the redo operation only involves the modification of the first before and after pointers between transaction record nodes on the doubly circular transaction chain. The physical storage location of the target transaction record and its associated target operation data in the memory block remains unchanged.
[0077] It should be noted that the tail removal and tail attachment operations of the transaction chain can be implemented using, but are not limited to, the pointer modification order described above. In practical applications, the front and rear pointers of the target transaction record itself can be updated first, and then the pointers of adjacent transaction records can be updated; or the addresses of adjacent transaction records can be stored in temporary variables, and the pointer updates can be completed step by step. This disclosure does not specifically limit this approach.
[0078] Using the above method, the logical ownership change of the target transaction record is achieved through node removal and attachment operations on the bidirectional circular transaction chain. The undo and redo operations adopt the same processing flow. The entire process only modifies the connection relationship of the first and last pointers. The physical storage location of the target transaction record and associated target operation data in the memory block does not need to be transferred.
[0079] Optionally, based on any of the above embodiments or optional methods, when the target transaction record changes its logical affiliation between the first storage stack and the second storage stack, the physical storage location of the target transaction record and its associated target operation data in the memory block remains unchanged.
[0080] In some embodiments, after the target transaction record and its associated target operation data are written into a contiguous memory space of a memory block in the first storage stack during the edit operation phase, their storage address in physical memory is determined. During subsequent undo or redo operations, the logical ownership change of the target transaction record is achieved by removing it from the tail of the doubly circular transaction chain of the original storage stack and attaching it to the tail of the doubly circular transaction chain of the target storage stack. This process only involves modifying the first forward and backward pointers of the target transaction record on the doubly circular transaction chain, and updating the first forward and backward pointers of adjacent transaction records in the original and target storage stacks.
[0081] Because the target transaction record and its associated target operation data are physically separated from their logical indexes in the transaction chain, the removal and attachment operations on the doubly circular transaction chain only change the pointer connection relationship of the transaction record nodes. That is, they change which storage stack's transaction chain manages the target transaction record, and do not affect the physical storage location of the target transaction record and its associated target operation data in the memory block. The data content of the target transaction record itself, the data content of the target operation data, and their storage space location in the memory block remain unchanged throughout the entire undo and redo process.
[0082] It should be noted that the separation of the logical ownership and physical storage location of the target transaction record can be achieved in ways including but not limited to the following: assigning a unique physical address identifier to each transaction record when writing data to the memory block, with the nodes on the transaction chain storing this physical address identifier instead of directly storing the data itself; or the transaction chain node itself is the starting address pointer of the transaction record in the memory block, and the removal and attachment operations directly modify the connection order of this pointer in the transaction chain. This disclosure does not limit the specific implementation method of separating logical ownership and physical storage location.
[0083] Using the above method, when the logical affiliation of the target transaction record changes between the first and second storage stacks, the physical storage location of its associated target operation data in the memory block remains unchanged. Undo and redo operations do not require physical copying or moving of the operation data, reducing the resource consumption of data processing and improving the operation response speed.
[0084] Optionally, based on any of the above embodiments or optional methods, the embodiments of this disclosure may also employ methods including but not limited to the following: Determine whether the total number of transaction records in each storage stack exceeds a preset threshold; If the total number of transaction records exceeds the preset threshold, the transaction record at the head of the bidirectional circular transaction chain of the storage stack will be removed. If the limit is not exceeded, the value remains unchanged.
[0085] In some embodiments, as the user continuously performs edit, undo, and redo operations, the number of transaction records on the bidirectional circular transaction chains in the first and second storage stacks gradually increases. To prevent the unlimited accumulation of transaction records from causing excessive storage space consumption, the system monitors the total number of transaction records in each storage stack. The total number of transaction records refers to the number of transaction record nodes currently attached to the bidirectional circular transaction chain of the storage stack. The preset threshold is a pre-set value used to limit the maximum number of transaction records that each storage stack is allowed to store simultaneously. The specific value of the preset threshold can be configured according to the actual application scenario, and this disclosure embodiment does not specifically limit it.
[0086] After each new transaction record is added to the storage stack, or after each logical ownership change of a transaction record is completed, the system checks whether the total number of transaction records in the storage stack exceeds a preset threshold. If the result is that the total number of transaction records does not exceed the preset threshold, the current state is maintained, and no transaction records in the storage stack are evicted.
[0087] If the system determines that the total number of transaction records exceeds a preset threshold, it will perform eviction processing on the storage stacks where the total number of transaction records exceeds the preset threshold. Eviction processing refers to removing the head transaction record from the doubly linked circular transaction chain of the storage stack. The head transaction record is the transaction record in the doubly linked circular transaction chain that is furthest from the current time, i.e., the earliest transaction record stored in the storage stack. Since the doubly linked circular transaction chain is a circular linked list structure with its head and tail connected, the head transaction record is the transaction record pointed to by the next pointer of the tail transaction record. The system removes the head transaction record from the doubly linked circular transaction chain by modifying the first next pointer of the adjacent transaction records before and after the head transaction record, so that the transaction record before and after the head transaction record is directly connected. After the removal operation is completed, the total number of transaction records in the doubly linked circular transaction chain of the storage stack is reduced by one, and the transaction record after the original head transaction record becomes the new head transaction record.
[0088] It should be noted that the triggering time for determining whether the total number of transaction records exceeds the preset threshold can be, but is not limited to, the following methods: judging immediately after each new transaction record is stored, judging periodically according to a preset time period, or judging when a new memory block is allocated in the memory block of the storage stack. The pointer modification order when removing the header transaction record can be, but is not limited to, modifying the pointers of adjacent transaction records first and then releasing the memory space occupied by the target transaction record, or temporarily storing the information of the target transaction record first and then performing pointer modification, etc. The embodiments of this disclosure do not specifically limit this.
[0089] Using the above method, the oldest transaction record is automatically eliminated when the total number of transaction records exceeds a preset threshold, preventing the unlimited accumulation of transaction records and ensuring that the memory usage of the storage stack is within a controllable range.
[0090] Optionally, based on any of the above embodiments or optional methods, after removing the transaction record at the head of the doubly circular transaction chain of the storage stack where the total number of transaction records exceeds the preset threshold, the method further includes: Detect whether there are other active transaction records in the memory block where the transaction record in the header is located; If it does not exist, release all memory space of the memory block containing the transaction record in the header, and remove the memory block containing the transaction record in the header from its doubly circular memory block chain. If it exists, then release the memory space within the memory block occupied by the transaction record in the header and its associated operation data.
[0091] In some embodiments, after a header transaction record is removed from the doubly linked circular transaction chain, the system needs to reclaim the physical storage space occupied by that header transaction record. The memory block containing the header transaction record refers to the memory block in which the header transaction record and its associated operation data are physically stored. An active transaction record refers to a transaction record within that memory block that is still managed by the doubly linked circular transaction chain and has not yet been removed or evicted.
[0092] The system first checks whether there are other active transaction records within the memory block containing the transaction record at the header. This detection can be implemented in ways including, but not limited to, the following: traversing all transaction records stored in the memory block and checking each record one by one whether it is still attached to a doubly linked circular transaction chain in a storage stack; or maintaining an active transaction count in each memory block, updating the count when a transaction record is removed or attached, and directly reading the count value during detection. This disclosure does not limit the specific detection method.
[0093] If the detection result indicates that there are no other active transaction records within the memory block containing the header transaction record, meaning all previously stored transaction records in that memory block have been removed or evicted, and no valid data needs to be retained, the system releases all memory space in that memory block, returning the physical memory occupied by it to the operating system or memory management system. Before releasing the physical memory, the system needs to remove the memory block from its doubly linked circular memory block chain. This is done by modifying the second pointers of the preceding and following memory blocks, so that the second pointer of the preceding block directly points to the following block, and the first pointer of the following block directly points to the preceding block, thus removing the memory block from the doubly linked circular memory block chain. Afterward, the system performs a physical memory release operation on the memory block, completing the reclamation of the entire memory block.
[0094] If the detection result indicates that there are still other active transaction records within the memory block containing the header transaction record (i.e., other transaction records managed by a transaction chain of a certain storage stack), the entire memory block cannot be released. The system only releases the storage space occupied by the header transaction record and its associated operation data within that memory block. This storage space release can be achieved by combining the Last-In-First-Out (LIFO) allocation and release mechanism of memory blocks. For example, the used position pointer of the memory block can be pushed back by the corresponding size of storage space, marking this space as available for reallocation. It should be noted that because memory block allocation and release follow the LIFO order, this space can only be immediately reclaimed and reused if the evicted header transaction record and its associated operation data are located at the end of the used storage space of the memory block. If the header transaction record is not located at the end of the used storage space of the memory block, this space is temporarily marked as released, waiting for all subsequent transaction records in the memory block to be removed before being reclaimed uniformly through the tail-back mechanism of the memory block. Specifically, the embodiments disclosed herein do not limit the implementation method of partial space release.
[0095] By using the above method, when the earliest transaction record is eliminated, different strategies such as releasing the entire block or releasing part of the block are adopted depending on whether there are other active transaction records in the memory block. This achieves fine-grained management of physical memory and avoids unnecessary occupation of memory space.
[0096] Optionally, based on any of the above embodiments or optional methods, the step of allocating memory space in the first storage stack and writing the target transaction record and its associated target operation data includes: Determine whether the remaining storage space size of the current memory block used for memory allocation in the bidirectional circular memory block chain of the first storage stack is greater than or equal to the size of the target transaction record and its associated target operation data, and obtain the determination result; If the determination result is yes, then allocate contiguous memory space at the end of the used storage space of the current memory block, and write the target transaction record and its associated target operation data. If the judgment result is negative, a new memory block is generated, and the new memory block is connected to the tail of the bidirectional circular memory block chain of the first storage stack through the second forward and backward pointers. A contiguous memory space is allocated in the new memory block, and the target transaction record and its associated target operation data are written.
[0097] In some embodiments, the current memory block refers to the memory block in a doubly linked circular memory block chain that is currently undergoing memory allocation, typically the most recently created or the most recently added memory block to the end of the chain. Used storage space refers to the storage area within the current memory block that has already been written to, and the end of the used storage space refers to the final boundary position of that used storage area. Remaining storage space size refers to the size of the available allocable storage space remaining after subtracting the used storage space from the total storage space of the current memory block.
[0098] When an edit command triggers the transaction record storage process, the system first calculates the storage space required for the target transaction record and its associated target operation data. The size of the target transaction record and its associated target operation data are determined during generation; their sum is the total storage space to be allocated. The system then obtains the remaining storage space of the current memory block in the doubly linked circular memory block chain of the first storage stack and compares this remaining storage space with the total storage space to be allocated.
[0099] If the remaining storage space of the current memory block is greater than or equal to the total storage space required for this write, it indicates that the current memory block has enough space to accommodate the data being written. Starting from the end of the used storage space of the current memory block, the system allocates a contiguous segment of storage space, the length of which is equal to the total storage space required for this write. The system sequentially writes the target transaction record and its associated target operation data into this contiguous storage space. After writing is complete, it updates the position of the end of the used storage space of the current memory block, shifting the end of the used storage space forward by the corresponding displacement.
[0100] If the remaining storage space of the current memory block is less than the total storage space required for this write, it indicates that the remaining space of the current memory block is insufficient to accommodate all the data being written. In this case, the system generates a new memory block. The newly generated memory block has a pre-defined size of contiguous physical storage space, and the total storage space size of the memory block can be configured according to the actual application scenario. The system connects the new memory block to the tail of the doubly circular memory block chain in the first storage stack using a second forward and backward pointer. The connection method is as follows: the forward pointer of the new memory block points to the tail memory block of the original doubly circular memory block chain, and the backward pointer points to the head memory block; simultaneously, the backward pointer of the original tail memory block and the forward pointer of the original head memory block are updated so that they both point to the new memory block. After connection, the new memory block becomes the new tail of the doubly circular memory block chain and also becomes the new current memory block. Within the new memory block, the system allocates contiguous storage space starting from the beginning of the memory block, writes the target transaction record and its associated target operation data into this contiguous storage space, and updates the end position of the used storage space of the new memory block after writing is complete.
[0101] Using the above method, the storage of transaction records and operation data follows a last-in-first-out linear allocation order, prioritizing contiguous allocation at the end of the current memory block. When space is insufficient, new memory blocks are automatically expanded, reducing the number of times memory is requested from the operating system. At the same time, the contiguous storage method avoids the generation of memory fragmentation.
[0102] Corresponding to the data processing method described above, the present invention also proposes a data processing apparatus. Since the apparatus embodiments of the present invention correspond to the method embodiments described above, details not disclosed in the apparatus embodiments can be referred to in the method embodiments described above, and will not be repeated here.
[0103] Figure 4 This is a schematic diagram of the structure of a data processing apparatus provided in an embodiment of the present disclosure, as shown below. Figure 4 As shown, the device includes: The first determining unit 41 is used to respond to the user's operation command and determine the direction of the push pointer and the pop-up pointer according to the command type of the operation command; The second determining unit 42 is used to determine the logical attribution of the target transaction record related to the operation instruction based on the direction of the push pointer and the pop-up pointer. The execution unit 43 is used to execute the operation instruction on the operation object based on the target operation data associated with the target transaction record.
[0104] The data processing device provided in this embodiment can determine the direction of the push pointer and the pop pointer according to the instruction type of the operation instruction, and determine the logical ownership of the target transaction record based on the pointer direction. This makes the undo or redo operation only involve the change of the logical ownership of the transaction record, without the need to physically transfer the transaction record and associated operation data between two storage stacks, thereby reducing the amount of data processing during the operation execution process and improving the operation response speed.
[0105] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 5 As shown, the first determining unit 41 includes: The first determining module 411 is used to determine, when the instruction type of the operation instruction is an edit instruction or a redo instruction, that the push pointer points to the first storage stack and the pop pointer points to the second storage stack. The second determining module 412 is used to determine, when the instruction type of the operation instruction is a cancel instruction, that the push pointer points to the second storage stack and the pop pointer points to the first storage stack.
[0106] Furthermore, in one possible implementation of the embodiments of this disclosure, such as Figure 5 As shown, the execution unit 43 includes: The first execution module 431 is used to respond to the editing instruction by storing the target transaction record and the associated target operation data into the first storage stack currently pointed to by the push pointer; The second execution module 432 is configured to, in response to the undo command, swap the pointers of the push pointer and the pop pointer, change the logical affiliation of the target transaction record from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer, and perform undo on the operation object based on the target operation data associated with the target transaction record; and restore the pointers of the push pointer and the pop pointer. The third execution module 433 is used to respond to the redo instruction by changing the logical affiliation of the target transaction record from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer, and performing a redo on the operation object based on the target operation data associated with the target transaction record.
[0107] Furthermore, in one possible implementation of this disclosure embodiment, the transaction records in each storage stack form a bidirectional circular transaction chain through first forward and backward pointers, and the first execution module 431 is further configured to: Memory space is allocated within the first storage stack, and the target transaction record and its associated target operation data are written therein; wherein, the first storage stack and the second storage stack each contain a bidirectional circular memory block chain consisting of multiple memory blocks linked by second forward and backward pointers; the target transaction record and its associated target operation data are stored in contiguous memory space within the same memory block; The target transaction record is appended to the tail of the bidirectional circular transaction chain of the first storage stack, and the first forward and backward pointers in the bidirectional circular transaction chain of the first storage stack are updated.
[0108] Furthermore, in one possible implementation of this disclosure, the second execution module 432 is further configured to: Remove the target transaction record from the tail of the bidirectional circular transaction chain of the first storage stack and attach it to the tail of the bidirectional circular transaction chain of the second storage stack. The third execution module is also used for: The target transaction record is removed from the tail of the bidirectional circular transaction chain of the second storage stack and attached to the tail of the bidirectional circular transaction chain of the first storage stack.
[0109] Furthermore, in one possible implementation of this disclosure embodiment, when the target transaction record changes its logical affiliation between the first storage stack and the second storage stack, the physical storage location of the target transaction record and its associated target operation data in the memory block remains unchanged.
[0110] Furthermore, in one possible implementation of this disclosure, the apparatus is further configured to: Determine whether the total number of transaction records in each storage stack exceeds a preset threshold; If the total number of transaction records exceeds the preset threshold, the transaction record at the head of the bidirectional circular transaction chain of the storage stack will be removed. If the limit is not exceeded, the value remains unchanged.
[0111] Furthermore, in one possible implementation of this disclosure, after removing the transaction record at the head of the bidirectional circular transaction chain of the storage stack whose total number of transaction records exceeds the preset threshold, the apparatus is further configured to: Detect whether there are other active transaction records in the memory block where the transaction record in the header is located; If it does not exist, release all memory space of the memory block containing the transaction record in the header, and remove the memory block containing the transaction record in the header from its doubly circular memory block chain. If it exists, then release the memory space within the memory block occupied by the transaction record in the header and its associated operation data.
[0112] Furthermore, in one possible implementation of this disclosure embodiment, the first execution module 431 is further configured to: Determine whether the remaining storage space size of the current memory block used for memory allocation in the bidirectional circular memory block chain of the first storage stack is greater than or equal to the size of the target transaction record and its associated target operation data, and obtain the determination result; If the determination result is yes, then allocate contiguous memory space at the end of the used storage space of the current memory block, and write the target transaction record and its associated target operation data. If the judgment result is negative, a new memory block is generated, and the new memory block is connected to the tail of the bidirectional circular memory block chain of the first storage stack through the second forward and backward pointers. A contiguous memory space is allocated in the new memory block, and the target transaction record and its associated target operation data are written.
[0113] It should be noted that the foregoing explanation of the method embodiments also applies to the apparatus of the embodiments of this disclosure, and the principle is the same. Therefore, the embodiments of this disclosure are not limited thereto.
[0114] According to embodiments of this disclosure, this disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0115] Figure 6 A schematic block diagram of an example electronic device 500 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0116] like Figure 6 As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory 502 or a computer program loaded from a storage unit 508 into a random access memory 503. The random access memory 503 may also store various programs and data required for the operation of the electronic device 500. The computing unit 501, the read-only memory 502, and the random access memory 503 are interconnected via a bus 504. An input / output interface 505 is also connected to the bus 504.
[0117] Multiple components in electronic device 500 are connected to input / output interface 505, including: input unit 506, such as keyboard, mouse, etc.; output unit 507, such as various types of monitors, speakers, etc.; storage unit 508, such as disk, optical disk, etc.; and communication unit 509, such as network card, modem, wireless transceiver, etc. Communication unit 509 allows electronic device 500 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0118] The computing unit 501 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, CPUs (Central Processing Units), GPUs (Graphics Processing Units), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, DSPs (Digital Signal Processors), and any suitable processor, controller, microcontroller, etc. The computing unit 501 performs the various methods and processes described above, such as data processing methods. For example, in some embodiments, the data processing methods may be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via read-only memory 502 and / or communication unit 509. When the computer program is loaded into random access memory 503 and executed by the computing unit 501, one or more steps of the methods described above may be performed. Alternatively, in other embodiments, the computing unit 501 may be configured to perform the aforementioned data processing method by any other suitable means (e.g., by means of firmware).
[0119] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, FPGAs (Field Programmable Gate Arrays), ASICs (Application-Specific Integrated Circuits), ASSPs (Application-Specific Standard Products), SOCs (System-on-Chips), CPLDs (Complex Programmable Logic Devices), computer hardware, firmware, software, and / or combinations thereof. These various implementations may include implementations in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which may be a dedicated or general-purpose programmable processor, capable of receiving data and instructions from a storage system, at least one input device, and at least one output device, and transmitting data and instructions to the storage system, the at least one input device, and the at least one output device.
[0120] The program code used to implement the methods of this disclosure may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.
[0121] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, RAM, ROM, EPROM (Electrically Programmable Read-Only Memory) or flash memory, optical fiber, CD-ROM (Compact Disc Read-Only Memory), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0122] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0123] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as data servers), or middleware components (e.g., application servers), or frontend components (e.g., user computers with graphical user interfaces or web browsers through which users can interact with implementations of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., communication networks). Examples of communication networks include LANs (Local Area Networks), WANs (Wide Area Networks), the Internet, and blockchain networks.
[0124] Computer systems can include clients and servers. Clients and servers are generally geographically separated and typically interact via communication networks. The client-server relationship is created by computer programs running on the respective computers and having a client-server relationship with each other. A server can be a cloud server, also known as a cloud computing server or cloud host, a hosting product within the cloud computing service system that addresses the shortcomings of traditional physical hosts and VPS (Virtual Private Server) services, such as high management difficulty and weak business scalability. Servers can also be servers for distributed systems or servers incorporating blockchain technology.
[0125] It's important to note that artificial intelligence (AI) is the study of enabling computers to simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). It encompasses both hardware and software technologies. AI hardware technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily include computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graph technologies.
[0126] It should be understood that the various forms of processes shown above can be used to rearrange, add, or delete steps. For example, the steps described in this disclosure can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution disclosed in this application can be achieved, and this is not limited herein.
[0127] The specific embodiments described above do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A data processing method, characterized in that, include: In response to the user's operation command, the direction of the push pointer and the pop-up pointer is determined according to the command type of the operation command; Based on the directions of the push pointer and the pop-up pointer, the logical attribution of the target transaction record related to the operation instruction is determined; The operation instruction is executed on the operation object based on the target operation data associated with the target transaction record.
2. The method according to claim 1, characterized in that, The step of responding to a user's operation command and determining the direction of the push pointer and pop-up pointer based on the command type of the operation command includes: If the instruction type of the operation instruction is an edit instruction or a redo instruction, it is determined that the push pointer points to the first storage stack and the pop pointer points to the second storage stack. When the instruction type of the operation instruction is a cancel instruction, it is determined that the push pointer points to the second storage stack and the pop pointer points to the first storage stack.
3. The method according to claim 2, characterized in that, The step of executing the operation instruction on the operation object based on the target operation data associated with the target transaction record includes: In response to the editing instruction, the target transaction record and the associated target operation data are stored in the first storage stack currently pointed to by the push pointer; In response to the undo command, the push pointer and the pop pointer are swapped, the logical affiliation of the target transaction record is changed from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer, and the operation object is undone based on the target operation data associated with the target transaction record; the points of the push pointer and the pop pointer are restored. In response to the redo instruction, the logical affiliation of the target transaction record is changed from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer, and a redo is performed on the operation object based on the target operation data associated with the target transaction record.
4. The method according to claim 3, characterized in that, The transaction records in each storage stack form a bidirectional circular transaction chain through first forward and backward pointers. The step of storing the target transaction record and the associated target operation data into the first storage stack currently pointed to by the push pointer includes: Memory space is allocated within the first storage stack, and the target transaction record and its associated target operation data are written therein; wherein, the first storage stack and the second storage stack each contain a bidirectional circular memory block chain consisting of multiple memory blocks linked by second forward and backward pointers; the target transaction record and its associated target operation data are stored in contiguous memory space within the same memory block; The target transaction record is appended to the tail of the bidirectional circular transaction chain of the first storage stack, and the first forward and backward pointers in the bidirectional circular transaction chain of the first storage stack are updated.
5. The method according to claim 4, characterized in that, The step of changing the logical affiliation of the target transaction record from the first storage stack currently pointed to by the pop pointer to the second storage stack currently pointed to by the push pointer includes: Remove the target transaction record from the tail of the bidirectional circular transaction chain of the first storage stack and attach it to the tail of the bidirectional circular transaction chain of the second storage stack. The step of changing the logical affiliation of the target transaction record from the second storage stack currently pointed to by the pop pointer to the first storage stack currently pointed to by the push pointer includes: The target transaction record is removed from the tail of the bidirectional circular transaction chain of the second storage stack and attached to the tail of the bidirectional circular transaction chain of the first storage stack.
6. The method according to claim 5, characterized in that, When the target transaction record changes its logical affiliation between the first storage stack and the second storage stack, the physical storage location of the target transaction record and its associated target operation data in the memory block remains unchanged.
7. The method according to claim 4, characterized in that, The method further includes: Determine whether the total number of transaction records in each storage stack exceeds a preset threshold; If the total number of transaction records exceeds the preset threshold, the transaction record at the head of the bidirectional circular transaction chain of the storage stack will be removed. If the limit is not exceeded, the value remains unchanged.
8. The method according to claim 7, characterized in that, After removing the head of the doubly circular transaction chain in the storage stack where the total number of transaction records exceeds the preset threshold, the method further includes: Detect whether there are other active transaction records in the memory block where the transaction record in the header is located; If it does not exist, release all memory space of the memory block containing the transaction record in the header, and remove the memory block containing the transaction record in the header from its doubly circular memory block chain. If it exists, then release the memory space within the memory block occupied by the transaction record in the header and its associated operation data.
9. The method according to claim 4, characterized in that, The step of allocating memory space within the first storage stack and writing the target transaction record and its associated target operation data includes: Determine whether the remaining storage space size of the current memory block used for memory allocation in the bidirectional circular memory block chain of the first storage stack is greater than or equal to the size of the target transaction record and its associated target operation data, and obtain the determination result; If the determination result is yes, then allocate contiguous memory space at the end of the used storage space of the current memory block, and write the target transaction record and its associated target operation data. If the judgment result is negative, a new memory block is generated, and the new memory block is connected to the tail of the bidirectional circular memory block chain of the first storage stack through the second forward and backward pointers. A contiguous memory space is allocated in the new memory block, and the target transaction record and its associated target operation data are written.
10. A data processing apparatus, characterized in that, include: The first determining unit is used to respond to the user's operation command and determine the direction of the push pointer and the pop-up pointer according to the command type of the operation command; The second determining unit is used to determine the logical attribution of the target transaction record related to the operation instruction based on the direction of the push pointer and the pop-up pointer. An execution unit is used to execute the operation instructions on the operation object based on the target operation data associated with the target transaction record.