A data processing method, apparatus and computer-readable medium
By creating proxy objects for reference type data and generating historical operation records, the problem of wasting time and memory resources during the modification history collection process in the existing technology is solved, and efficient modification history collection is achieved.
Patent Information
- Application Number
- CN202210531317.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-16
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2042-05-16
AI Technical Summary
In the prior art, the calculation time cost is high in the history of the reference type data collection process and the memory resources are wasted, making it difficult to efficiently collect the history of changes.
By creating a first proxy object for the target data, obtaining attribute trigger instructions and responding to the instructions to generate historical operation records, directly intercepting and recording access, assignment, addition and deletion operations.
It can effectively collect the history of changes of reference type data without deep traversal and comparison, reducing the amount of computing and memory resource consumption.
Smart Images

Figure CN114911772B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a data processing method, device and computer-readable medium. Background Art
[0002] In JavaScript, container data is nested data, which is also called reference type data, such as object type data and array type data. Currently, there are two ways to modify reference type data.
[0003] The first method is that when the internal attributes or elements of the reference type data are modified, the value of the reference type data itself will not change. For example, for nested data A, after the E value corresponding to Key4 in A.Key1.Key4 is changed to F, the only change in the entire nested data A is the change in the value of Key4, while other locations, such as the attribute values corresponding to the outer layer A of the nested data and the key1 key in A, have not changed. Therefore, this method cannot be used to observe whether the nested data A has changed from the value of the outer layer A of the nested data, and then it is difficult to collect its change history. The second method is the immutable data body technology, which first declares the variable of the immutable data body, and then modifies the nested data in the variable, such as assigning a key value to an object in the nested data, deleting a key of the object, adding a key-value pair of the object, assigning or deleting an element at a certain position in the array, or increasing or decreasing the number of elements in the array, etc. Since these modification, addition, and deletion operations will result in a new data body being generated, for example, after the value of E corresponding to Key4 in A.Key1.Key4 is changed to F, E in the returned result is replaced by F; since E is the value inside the attribute value (object B) corresponding to Key1 in object A, the object B in the returned result is replaced by the new object B'; similarly, the change in object B causes object A to be replaced by the new object A'. In this immutable data body technology, the unchanged part still uses the original value. Although this method can infer changes to the nested data A from the value of the outer layer A of the nested data, it is still difficult to collect its change history.
[0004] In the prior art, if developers need to collect the change history of such nested data, the general method is to obtain a historical snapshot by deeply copying the nested data before and after it is changed, and then use the tree data deep traversal comparison method to calculate the difference, thereby obtaining the data change history. Therefore, the existing data change history collection, whether facing immutable data or conventional reference type data, is mainly through the deep traversal comparison method. Both of the above methods require the use of the before-and-after snapshot comparison method, which will cause a large memory usage; in addition, when performing deep traversal comparison, it will also consume a lot of computing time and resources. Summary of the Invention
[0005] The present invention provides a data processing method, apparatus and computer-readable medium. This method can directly and effectively collect the change results of reference type data without executing any algorithms, solves the problems of large consumption of calculation time and resource occupation caused by calculating differences using the deep traversal comparison method in the prior art, and reduces the calculation amount in the process of collecting change history.
[0006] To achieve the above object, according to the first aspect of the embodiments of the present application, a data processing method is provided. Specifically, a corresponding first proxy object is created for the target data, where the target data is a container data of reference type; an attribute trigger instruction for the first proxy object is obtained; in response to the attribute trigger instruction, an operation corresponding to the attribute trigger instruction is performed on the target data to generate a historical operation record.
[0007] Optionally, creating a corresponding first proxy object for the target data includes: determining whether a first proxy object corresponding to the target data exists in the cache area; if not, a corresponding first proxy object is created for the target data based on the target data and the attribute operation interface corresponding to the target data.
[0008] Optionally, if the attribute trigger instruction is used to indicate intercepting the access attribute operation of the target data through the first proxy object; performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record includes: obtaining the access path of the target data; accessing the attribute of the target data based on the access path to obtain an attribute value; if the attribute value is an object, a corresponding second proxy object is created for the attribute value; an access operation record is generated based on the parent-child relationship between the first proxy object and the second proxy object and the access path.
[0009] Optionally, if the attribute trigger instruction is used to indicate intercepting the current change attribute operation of the target data through the first proxy object; the attribute operation instruction includes the current change attribute and the change path; performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record includes: using the current change attribute as a child node, obtaining the parent node corresponding to the child node from the target data; determining whether the change path exists in the parent node; based on the determination result, determining the current change attribute operation intercepted by the first proxy object to generate a change operation record.
[0010] Optionally, when the attribute operation instruction further includes the new value corresponding to the currently modified attribute; based on the judgment result, determining the currently modified attribute operation intercepted by the first proxy object, and generating a modification operation record, including: if the judgment result indicates that the parent node has the modification path, determining that the currently modified attribute operation intercepted by the first proxy object is an assignment operation, and obtaining the old value corresponding to the child node from the target data; generating an assignment operation record based on the parent node, the modification path, and the new value and the old value corresponding to the child node; if the judgment result indicates that the parent node does not have the modification path, determining that the currently modified attribute operation intercepted by the first proxy object is an addition operation; generating an addition operation record based on the parent node, the modification path, and the new value corresponding to the child node.
[0011] Optionally, when the attribute operation instruction does not include the new value corresponding to the currently modified attribute; based on the judgment result, determining the currently modified attribute operation intercepted by the first proxy object, and generating a modification operation record, including: if the judgment result indicates that the parent node has the modification path and the modification path can be deleted, determining that the currently modified attribute operation intercepted by the first proxy object is a deletion operation; generating a deletion operation record based on the parent node, the modification path, and the child node.
[0012] Optionally, the method further includes: obtaining a modification path request starting from the target data for the currently modified attribute; querying, based on the modification path request, the parent node corresponding to the currently modified attribute from the modification operation record; using the parent node as the currently queried child node, and querying the parent node corresponding to the currently modified attribute from the access operation record; repeating the above query operation until the parent node is the target data, then ending the query operation and generating a new modification operation record.
[0013] To achieve the above object, according to a second aspect of the embodiments of the present application, a data processing device is provided. Among them, a creation module is used to create a corresponding first proxy object for the target data, where the target data is a container data of a reference type; a first acquisition module is used to acquire an attribute trigger instruction for the first proxy object; an execution module is used to, in response to the attribute trigger instruction, perform an operation corresponding to the attribute trigger instruction on the target data and generate a historical operation record.
[0014] Optionally, the creation module includes: a judgment unit for judging whether there is a first proxy object corresponding to the target data in the cache area; a creation unit for, if not, creating a corresponding first proxy object for the target data based on the target data and the attribute operation interface corresponding to the target data.
[0015] To achieve the above object, according to a third aspect of the embodiments of the present application, a computer-readable medium is further provided, on which a computer program is stored, and when the program is executed by a processor, the method described in the first aspect is implemented.
[0016] Compared with the prior art, the embodiments of the present invention provide a data processing method, apparatus, and computer-readable medium; the method first creates a corresponding first proxy object for target data, where the target data is container data of reference type; then obtains an attribute trigger instruction for the first proxy object; and finally, in response to the attribute trigger instruction, performs an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record. Thus, without the need for later calculation, the change history of reference type data can be effectively collected, solving the problems in the prior art that due to the later use of the deep traversal and comparison method to calculate the differences in reference type data before and after changes, the calculation time cost is large and memory resources are wasted during the change history collection process, and reducing the calculation amount during the change history collection process. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Some specific embodiments of the present invention will be described in detail hereinafter with reference to the drawings in an exemplary but not restrictive manner. The same reference numerals in the drawings denote the same or similar components or parts. Those skilled in the art should understand that these drawings are not necessarily drawn to scale. In the drawings:
[0018] Figure 1 is a schematic structural diagram of using a first method to modify reference type data in the prior art;
[0019] Figure 2 is a schematic structural diagram of using a second method to modify reference type data in the prior art;
[0020] Figure 3 is a schematic flowchart of a data processing method provided by an embodiment of the present invention;
[0021] Figure 4 is a schematic flowchart of generating an access operation record in an embodiment of the present invention;
[0022] Figure 5 is a schematic flowchart of generating an assignment operation record and an addition operation record in an embodiment of the present invention;
[0023] Figure 6 is a schematic flowchart of generating a deletion operation record in an embodiment of the present invention;
[0024] Figure 7 is a schematic structural diagram of a first proxy object corresponding to target data in an embodiment of the present invention.
[0025] Figure 8For Figure 4 Structural schematic diagram of the internal access path and access operation record of target data;
[0026] Figure 9 For Figure 5 Structural schematic diagram of the internal modification path and assignment operation record of the target data shown;
[0027] Figure 10 For Figure 6 Structural schematic diagram of the internal modification path and deletion operation record of the target data shown;
[0028] Figure 11 Structural schematic diagram of the data processing device provided by an embodiment of the present invention. Detailed implementation manners
[0029] To make the objectives, features, and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present invention.
[0030] As Figure 1 shown, it is a structural schematic diagram of modifying reference type data by using the first method in the prior art. The outermost layer of the nested data A is the object A; inside the object A, there are the Key1 key and the Key2 key, where the attribute value corresponding to the Key1 key is the object B, and the attribute value corresponding to the Key2 key is C; inside the object B, there are the Key3 key and the Key4 key, where the attribute value corresponding to the Key3 key is D, and the attribute value corresponding to the Key4 key is E. After performing an assignment operation on the nested data A, that is, modifying the E value corresponding to the Key4 key inside the nested data A to the F value, there is no change in the outermost object A of the nested data A. Therefore, it is difficult to observe the internal changes through the outermost layer of the nested data A.
[0031] As Figure 2 shown, it is a structural schematic diagram of modifying reference type data by using the second method in the prior art.
[0032] The outermost layer of the nested data A is the object A; inside the object A, there are the keys Key1 and Key2. The property value corresponding to the key Key1 is the object B, and the property value corresponding to the key Key2 is C; inside the object B, there are the keys Key3 and Key4. The property value corresponding to the key Key3 is D, and the property value corresponding to the key Key4 is E. Based on the immutable data body technology, an assignment operation is performed on the nested data A, that is, the value E corresponding to the key Key4 inside the nested data A is modified to the value F. The value E is the property value of the object B. Since the value E has changed, the object B in the return result is replaced with the object B'; the object B is the property value of the object A. Since the object B has changed, the object A in the return result is replaced with the new object A'. The unchanged parts in the nested data A still use the original values, such as Figure 2 the property values D and C in.
[0033] As Figure 3 shown, it is a schematic flowchart of the data processing method provided by an embodiment of the present invention; as Figure 7 shown, it is a schematic structural diagram of creating a first proxy object for the target data in an embodiment of the present invention. A data processing method at least includes the following steps: S301, creating a corresponding first proxy object for the target data, where the target data is a container data of reference type; S302, obtaining an attribute trigger instruction for the first proxy object; S303, in response to the attribute trigger instruction, performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record.
[0034] In S301, the container data of reference type is also called nested data.
[0035] By controlling the createReactivity function, using the characteristics of JavaScript's Proxy to create a first proxy object for the target data, and the first proxy object is used to intercept the basic operations of the target data. The basic operations can be operations such as access, assignment, addition, or deletion. For example, creating a first proxy object A' for the outermost object A of the target data to obtain a proxy relationship mapping, as Figure 7 shown.
[0036] In 302 and S303, when the attribute trigger instruction is used to indicate intercepting the access attribute operation of the target data through the first proxy object, in response to this attribute trigger instruction, an access operation is performed on the current attribute inside the target data to generate an access operation record.
[0037] When the attribute trigger instruction is used to indicate intercepting the assignment operation of the current modified attribute of the target data through the first proxy object; in response to this attribute trigger instruction, an assignment operation is performed on the current modified attribute inside the target data to generate an assignment operation record.
[0038] When the attribute trigger instruction is used to indicate intercepting the addition operation of the currently modified attribute of the target data through the first proxy object; in response to the attribute trigger instruction, an addition operation is performed on the currently modified attribute inside the target data, and an addition operation record is generated.
[0039] When the attribute trigger instruction is used to indicate intercepting the deletion operation of the currently modified attribute of the target data through the first proxy object; in response to the attribute trigger instruction, a deletion operation is performed on the currently modified attribute inside the target data, and a deletion operation record is generated.
[0040] In a preferred implementation manner of the first embodiment, creating a corresponding first proxy object for the target data includes: determining whether there is a first proxy object corresponding to the target data in the cache area; if not, creating a corresponding first proxy object for the target data based on the target data and the attribute operation interface corresponding to the target data.
[0041] Specifically, first initialize the buffer area corresponding to the target data. The initialized buffer area is used to store the proxy object of the target data and the historical operation records; then determine whether the parameter passed into the createReactivity function belongs to the reference type to obtain a first judgment result; if the first judgment result indicates that the parameter is not of the reference type, an error prompt is given; if the first judgment result indicates that the parameter is of the reference type, then continue to determine whether the parameter is the first proxy object that has been processed by the createReactivity function and corresponds to the target data to obtain a second judgment result; if the second judgment result indicates that the parameter is the first proxy object that has been processed by the createReactivity function and corresponds to the target data, then directly return the first proxy object; if the second judgment result indicates that the parameter is not the first proxy object that has been processed by the createReactivity function and corresponds to the target data, then determine whether there is a first proxy object corresponding to the target data in the cache area; if not, create a corresponding first proxy object for the target data based on the target data and the internal attribute operation interface corresponding to the target data. Here, the attribute operation interface is used to indicate multiple attribute interception methods inside the target data.
[0042] The method of the embodiment of the present invention first creates a corresponding first proxy object for the target data, where the target data is a container data of reference type; then obtains an attribute trigger instruction for the first proxy object; and finally, in response to the attribute trigger instruction, performs an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record. Thus, without post-computation, the change history of reference type data can be effectively collected, solving the problems in the prior art that due to the later use of the deep traversal and comparison method to calculate the differences between the reference type data before and after the change, the computational time cost is large and the memory resources are wasted during the change history collection process, and reducing the computational amount in the change history collection process.
[0043] In another preferred embodiment of this embodiment, as Figure 4 shown, it is a schematic flowchart of generating an access operation record in an embodiment of the present invention; as Figure 8 shown, it is Figure 4 a schematic structural diagram of the internal access path and access operation record of the target data in
[0044] If the attribute trigger instruction is used to indicate intercepting the access attribute operation of the target data through the first proxy object; performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record, at least including the following steps: S401, obtaining the access path of the target data; S402, accessing the attribute of the target data based on the access path to obtain the attribute value; S403, if the attribute value is an object, creating a corresponding second proxy object for the attribute value; S404, generating an access operation record based on the parent-child relationship between the first proxy object and the second proxy object and the access path.
[0045] Specifically, if the target data is an object or an array, then use the Reflect.get function to access the attributes of the target data with native semantics to obtain the attribute value; if the attribute value is not an object, return the value; if the attribute value is an object, then use the createReactivity function to process the value to obtain the second proxy object corresponding to the target data; finally, record the parent-child relationship between the first proxy object and the second proxy object and the access path in the cache area to generate an access operation record. If the target data is an array and the attribute accessed for the target data belongs to a method on the array prototype chain, such as push, pop, slice, indexOf, etc., then obtain the corresponding method from the target data.
[0046] For example, for the nested data A, the first proxy object A' can be obtained after being processed by the createReactivity function. When intercepting the access attribute operation of the nested data A through the first proxy object A', if accessing the attribute of the nested data A based on the access path Key1, and the obtained attribute value is the object B. Since this attribute value is an object, a corresponding second proxy object B' is created for this attribute value. Based on the parent-child relationship between the first proxy object A' and the second proxy object B' and the access path Key1, an access operation record is generated, that is, a parent-child relationship record, such as Figure 8 as shown; and this access operation record is stored in the cache area.
[0047] If accessing the attribute of the nested data A based on the access path Key2, and the obtained attribute value is C. Since C is not an object, the original value can be directly returned. Based on the parent-child relationship between the first proxy object A' and the attribute value C and the access path Key2, another access operation record is generated; similarly, this access operation record is stored in the cache area.
[0048] Thus, it is possible to intercept the access operation inside the target data through the first proxy object, so that the access operation record of the target data can be effectively obtained.
[0049] In another preferred embodiment of this embodiment, if the attribute trigger instruction is used to indicate intercepting the current modified attribute operation of the target data through the first proxy object; the attribute operation instruction includes the current modified attribute and the modification path; performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record, which at least includes the following steps: using the current modified attribute as a child node, obtaining the corresponding parent node from the target data; judging whether the modification path exists in the parent node; based on the judgment result, determining the current modified attribute operation intercepted by the first proxy object, and generating a modification operation record.
[0050] As Figure 5 shown, it is a schematic flowchart of generating an assignment operation record and an addition operation record in an embodiment of the present invention; as Figure 9 shown, it is Figure 5 a schematic structural diagram of the internal modification path of the target data and the assignment operation record as shown.
[0051] In a preferred embodiment, if the attribute trigger instruction is used to indicate intercepting the current modified attribute operation of the target data through the first proxy object; the attribute operation instruction includes the current modified attribute and the modification path; performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record, including at least the following steps: S501, taking the current modified attribute as a child node, and obtaining the parent node corresponding to the child node from the target data; S502, determining whether the parent node has a modification path; S503, if the determination result indicates that the parent node has a modification path, determining that the current modified attribute operation intercepted by the first proxy object is an assignment operation, and obtaining the old value corresponding to the child node from the target data; generating an assignment operation record based on the parent node, the modification path, and the new value and the old value corresponding to the child node; S504, if the determination result indicates that the parent node does not have a modification path, determining that the current modified attribute operation intercepted by the first proxy object is an addition operation; generating an addition operation record based on the parent node, the modification path, and the new value corresponding to the child node.
[0052] Specifically, when the target data is an array, if the attribute key corresponding to the parent node in the array is a number and the size of the number is less than the length of the array, it is determined that the parent node in the array has the modification path, then the current modified attribute operation intercepted by the first proxy object is an assignment operation; otherwise, it is determined that the parent node in the array does not have the modification path, then the current modified attribute operation intercepted by the first proxy object is an addition operation.
[0053] When the target data is an object, if the parent node in the object has the modification path, it is determined that the parent node has the modification path, then the current modified attribute operation intercepted by the first proxy object is an assignment operation; otherwise, it is determined that the parent node in the object does not have the modification path, then the current modified attribute operation intercepted by the first proxy object is an addition operation.
[0054] After that, the target data is accessed through the first proxy object to obtain the old value corresponding to the child node. The finally generated assignment operation record and addition operation record are both stored in the cache area.
[0055] For example: performing an assignment operation on the nested data A, making it the second proxy object B'.Key4 = F. Then the above assignment interception logic will replace E in the original unproxied object A with F, and record the modification history. The generated modification history record is as Figure 9 shown.
[0056] Thus, through the first proxy object, the assignment operation or addition operation inside the target data can be intercepted, so that the assignment operation record or addition operation record of the target data can be effectively obtained.
[0057] Such as Figure 6As shown, it is a schematic flowchart of generating a deletion operation record in an embodiment of the present invention; as Figure 10 shown, it is Figure 6 a schematic structural diagram of the internal change path of the target data and the deletion operation record as shown.
[0058] In a preferred embodiment, if the attribute trigger instruction is used to indicate intercepting the current change attribute operation of the target data through the first proxy object; the attribute operation instruction includes the current change attribute and the change path; performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record, which at least includes the following steps: S601, taking the current change attribute as a child node, and obtaining the parent node corresponding to the child node from the target data; S602, determining whether the parent node has a change path; S603, if the judgment result indicates that the parent node has a change path and the change path can be deleted, determining that the current attribute operation intercepted by the first proxy object is a deletion operation; generating a deletion operation record based on the parent node, the change path, and the child node; S604, if the judgment result indicates that the parent node does not have a change path or has a change path but the change path cannot be deleted, determining that the current attribute operation intercepted by the first proxy object cannot be executed.
[0059] For example, if the parent node does not have a change path, the deletion operation is performed according to the native semantics, and no deletion operation record is generated; if the parent node has a change path, but the parent node is frozen or the change path of the parent node cannot be deleted, the current operation cannot be executed.
[0060] For example, when deleting B'.Key4 of the second proxy object, the above-mentioned deletion operation interception logic will delete E in the original un-proxied object A and record the change history, and the generated change history record is as Figure 10 shown.
[0061] Thus, through the first proxy object, the deletion operation inside the target data can be intercepted, so that the deletion operation record of the target data can be effectively obtained.
[0062] In another preferred embodiment of the present invention, the data processing method further includes the following operation steps: for the current change attribute, obtaining a change path request starting from the target data; based on the change path request, querying the parent node corresponding to the current change attribute from the change operation record; taking the parent node as the current queried child node, and querying the parent node corresponding to the current change attribute from the access operation record; repeating the above query operation until the queried parent node is the target data, then ending the query operation and generating a new change operation record.
[0063] Specifically, in the usage phase, this solution will provide a function named produce to accept data changes. This function takes a callback as a parameter. Inside this callback, the business side can perform corresponding operations using assignment and deletion operation writing methods that are no different from the general writing methods.
[0064] The following steps will be executed inside this produce function: clear the above-mentioned array used for change history records; execute the callback parameter; and return the above-mentioned array used for change history records as the return value. The data change operations in the callback function will trigger the above-mentioned property interception. Then the business side can obtain the historical operation records from the return value of the produce function.
[0065] Thus, for any current changed property in the change operation record, an access path starting from the top layer of the target data can be queried from the access operation record, so as to obtain a more complete change operation record, improve the efficiency of collecting the change history of the target data, reduce the unnecessary resource occupation in the traditional method, and improve the data processing speed.
[0066] It should be understood that in various embodiments of the present invention, the magnitudes of the sequence numbers of the above-mentioned processes do not mean the order of execution. The execution order of each process should be determined according to its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
[0067] As Figure 11 shown, in an embodiment of the present invention, there is a data processing device. The device 110 includes: a creation module 111, configured to create a corresponding first proxy object for the target data, where the target data is a container data of reference type; a first acquisition module 112, configured to acquire an attribute trigger instruction for the first proxy object; and an execution module 113, configured to, in response to the attribute trigger instruction, perform an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record.
[0068] In an optional embodiment, the creation module includes: a judgment unit, configured to judge whether there is a first proxy object corresponding to the target data in the cache area; and a creation unit, configured to, if not, create a corresponding first proxy object for the target data based on the target data and the attribute operation interface corresponding to the target data.
[0069] In an alternative embodiment, if the attribute trigger instruction is used to indicate intercepting an access attribute operation of the target data through the first proxy object; the execution module includes: a first acquisition unit, configured to acquire an access path of the target data; an access unit, configured to access an attribute of the target data based on the access path to obtain an attribute value; a creation unit, configured to create a corresponding second proxy object for the attribute value if the attribute value is an object; a first generation unit, configured to generate an access operation record based on a parent-child relationship between the first proxy object and the second proxy object and the access path.
[0070] In an alternative embodiment, if the attribute trigger instruction is used to indicate intercepting a current change attribute operation of the target data through the first proxy object; the attribute operation instruction includes a current change attribute and a change path; the execution module includes: a second acquisition unit, configured to use the current change attribute as a child node and acquire a parent node corresponding to the child node from the target data; a judgment unit, configured to judge whether the change path exists in the parent node; a second generation unit, configured to determine, based on a judgment result, a current change attribute operation intercepted by the first proxy object and generate a change operation record.
[0071] In an alternative embodiment, when the attribute operation instruction further includes a new value corresponding to the current change attribute; the second generation unit includes: a first generation subunit, configured to determine that the current change attribute operation intercepted by the first proxy object is an assignment operation if the judgment result indicates that the change path exists in the parent node, and acquire an old value corresponding to the child node from the target data; generate an assignment operation record based on the parent node, the change path, and the new value and the old value corresponding to the child node; a second generation subunit, configured to determine that the current change attribute operation intercepted by the first proxy object is an addition operation if the judgment result indicates that the change path does not exist in the parent node; generate an addition operation record based on the parent node, the change path, and the new value corresponding to the child node.
[0072] In an alternative embodiment, when the attribute operation instruction does not include a new value corresponding to the current change attribute; the second generation unit includes: a third generation subunit, configured to determine that the current attribute operation intercepted by the first proxy object is a deletion operation if the judgment result indicates that the change path exists in the parent node and the change path can be deleted; generate a deletion operation record based on the parent node, the change path, and the child node.
[0073] In an alternative embodiment, the apparatus further includes: a second acquisition module, configured to acquire a change path request starting from the target data for the current change attribute; a first query module, configured to query, based on the change path request, a parent node corresponding to the current change attribute from the change operation records; a second query module, configured to query, with the parent node as the current query child node, a grandparent node corresponding to the current change attribute from the access operation records; and a generation module, configured to repeat the above query operations until it is queried that the grandparent node is the target data, and then end the query operation and generate a new change operation record.
[0074] The above apparatus can execute the data processing method provided in an embodiment of the present invention, and has functional modules and beneficial effects corresponding to executing the picture display method. For technical details not described in detail in this embodiment, reference can be made to the data processing method provided in the embodiments of the present invention.
[0075] The present invention further provides an electronic device, including: a processor; a memory for storing executable instructions of the processor; and the processor, configured to read the executable instructions from the memory and execute the instructions to implement the data processing method of the present invention.
[0076] In addition to the above methods and devices, an embodiment of the present application may also be a computer program product, which includes computer program instructions that, when run by a processor, cause the processor to execute the steps in the methods according to various embodiments of the present application described in the "Exemplary Method" section above of this specification.
[0077] The computer program product can be written in any combination of one or more programming languages for programming code to execute the operations of the embodiments of the present application. The programming languages include object-oriented programming languages such as Java, C++, etc., and also include conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, executed as an independent software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0078] In addition, an embodiment of the present application may also be a computer-readable storage medium, on which computer program instructions are stored, and the computer program instructions, when run by a processor, cause the processor to execute the steps in the methods according to various embodiments of the present application described in the "Exemplary Method" section above of this specification.
[0079] The computer-readable storage medium may adopt any combination of one or more readable media. The readable media may be a readable signal medium or a readable storage medium. The readable storage medium may include, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (a non-exhaustive list) of the readable storage medium include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0080] The basic principles of the present application have been described above in conjunction with specific embodiments. However, it should be noted that the advantages, benefits, effects, etc. mentioned in the present application are only examples and not limitations. It cannot be considered that these advantages, benefits, effects, etc. are essential for each embodiment of the present application. In addition, the above-disclosed specific details are only for illustrative and easy-to-understand purposes, rather than limitations. The above details do not limit the present application to necessarily adopt the above specific details for implementation.
[0081] The block diagrams of the devices, apparatuses, equipment, and systems involved in the present application are only illustrative examples and do not intend to require or imply that they must be connected, arranged, and configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, equipment, and systems can be connected, arranged, and configured in any manner. Words such as "including", "comprising", "having", etc. are open-ended words, meaning "including but not limited to", and can be used interchangeably with each other. The word "or" and "and" used herein refer to the word "and / or", and can be used interchangeably with each other, unless the context clearly indicates otherwise. The word "such as" used herein refers to the phrase "such as but not limited to", and can be used interchangeably with each other.
[0082] It should also be noted that in the devices, equipment, and methods of the present application, each component or each step can be decomposed and / or recombined. These decompositions and / or recombinations should be regarded as equivalent solutions of the present application.
[0083] The above description of the disclosed aspects enables any person skilled in the art to make or use the present application. Various modifications to these aspects are very obvious to those skilled in the art, and the general principles defined herein can be applied to other aspects without departing from the scope of the present application. Therefore, the present application is not intended to be limited to the aspects shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.
[0084] The foregoing description has been presented for purposes of illustration and description. In addition, this description is not intended to limit the embodiments of the present application to the forms disclosed herein. Although multiple example aspects and embodiments have been discussed above, those skilled in the art will recognize some of their variations, modifications, alterations, additions, and sub-combinations.
[0085] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples", etc. means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. Moreover, the specific features, structures, materials, or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, without contradiction, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples.
[0086] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly indicating the quantity of the indicated technical features. Thus, the features defined with "first" and "second" may explicitly or implicitly include at least one of such features. In the description of the present invention, "a plurality of" means two or more unless otherwise specifically defined.
[0087] As described above, the foregoing are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily conceive of changes or substitutions within the technical scope disclosed by the present invention and should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A data processing method, wherein, Create a corresponding first proxy object for the target data, wherein the target data is a container data of reference type; Obtain an attribute trigger instruction for the first proxy object; If the attribute trigger instruction is used to indicate intercepting the current changed attribute operation of the target data through the first proxy object; the current changed attribute operation includes a current changed attribute and a change path; use the current changed attribute as a child node, and obtain the corresponding parent node from the target data for the child node; determine whether the parent node has a change path; based on the determination result, determine the current changed attribute operation intercepted by the first proxy object, and generate a change operation record; The determining, based on the determination result, the current changed attribute operation intercepted by the first proxy object and generating a change operation record includes: When the attribute trigger instruction further includes a new value corresponding to the current changed attribute, if the determination result indicates that the parent node has the change path, determine that the current changed attribute operation intercepted by the first proxy object is an assignment operation; in response to the attribute trigger instruction, perform an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record.
2. The method according to claim 1, wherein, The creating a corresponding first proxy object for the target data includes: Determine whether there is a first proxy object corresponding to the target data in the cache area; If not, create a corresponding first proxy object for the target data based on the target data and the attribute operation interface corresponding to the target data.
3. The method according to claim 1, wherein If the attribute trigger instruction is used to indicate intercepting the access attribute operation of the target data through the first proxy object; The performing an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record includes: Obtain the access path of the target data; Access the attribute of the target data based on the access path to obtain an attribute value; If the attribute value is an object, create a corresponding second proxy object for the attribute value; Generate an access operation record based on the parent-child relationship between the first proxy object and the second proxy object and the access path.
4. The method according to claim 1, wherein, When the attribute trigger instruction further includes a new value corresponding to the current changed attribute; the determining, based on the determination result, the current changed attribute operation intercepted by the first proxy object and generating a change operation record includes: If the determination result indicates that the parent node does not have the change path, determine that the current changed attribute operation intercepted by the first proxy object is an addition operation; generate an addition operation record based on the parent node, the change path, and the new value corresponding to the child node.
5. The method according to claim 1, wherein When the attribute trigger instruction does not include a new value corresponding to the current changed attribute; the determining, based on the determination result, the current changed attribute operation intercepted by the first proxy object and generating a change operation record includes: If the determination result indicates that the parent node has the change path and the change path can be deleted, determine that the current attribute operation intercepted by the first proxy object is a deletion operation; Generate a deletion operation record based on the parent node, the change path, and the child node.
6. The method according to claim 1, wherein, Further included: Obtain a change path request starting from the target data for the current change attribute; Based on the change path request, query the parent node corresponding to the current change attribute from the change operation record; Use the parent node as the currently queried child node, and query the parent node corresponding to the current change attribute from the access operation record; Repeat the above query operation until the queried parent node is the target data, then end the query operation and generate a new change operation record.
7. A data processing device, wherein A creation module, configured to create a corresponding first proxy object for the target data, where the target data is a container data of reference type; A first acquisition module, configured to acquire an attribute trigger instruction for the first proxy object; An execution module, configured to, if the attribute trigger instruction is used to indicate intercepting the current change attribute operation of the target data through the first proxy object; the current change attribute operation includes a current change attribute and a change path; use the current change attribute as a child node, and obtain a parent node corresponding to the child node from the target data; determine whether the parent node has a change path; based on the determination result, determine the current change attribute operation intercepted by the first proxy object, and generate a change operation record; The determining, based on the determination result, the current change attribute operation intercepted by the first proxy object and generating a change operation record; includes: when the attribute trigger instruction further includes a new value corresponding to the current change attribute, if the determination result indicates that the parent node has the change path, then determine that the current change attribute operation intercepted by the first proxy object is an assignment operation; in response to the attribute trigger instruction, perform an operation corresponding to the attribute trigger instruction on the target data to generate a historical operation record.
8. The apparatus according to claim 7, wherein, The creation module includes: A judgment unit, configured to judge whether there is a first proxy object corresponding to the target data in the cache area; A creation unit, configured to, if not, create a corresponding first proxy object for the target data based on the target data and the attribute operation interface corresponding to the target data.
9. A computer-readable medium, on which a computer program is stored, and when the program is executed by a processor, the method described in any one of claims 1-6 is implemented.