Data storage method and device, computer equipment and computer readable storage medium
By converting the running data generated by the application, the language format matches the format of the stored program, the problem of inconsistency between the application and the stored program language is solved, cross-language data storage is realized, and the universality of stored programs is improved. .
Patent Information
- Application Number
- CN202310841872.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-10
- Publication Date
- 2025-01-10
AI Technical Summary
In the prior art, the inconsistency between the programming language of the stored program results in the inability to effectively store the running data generated by the application.
By obtaining the running data generated by the application and converting it until the language format of the target running data matches the language format of the stored program, then the stored program is called to store the target running data.
It realizes data storage interoperability between different programming languages, improves the universality of stored programs, and avoids storage failures caused by language mismatch.
Smart Images

Figure CN119293104A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer equipment, and in particular to a data storage method, device, computer equipment and computer-readable storage medium. Background Art
[0002] As applications are developed, users have an increasing demand for storage of application-related data. In order to ensure data persistence, the data needs to be stored in a database.
[0003] In the conventional technology, data is stored by calling a stored procedure. However, when the programming language of the application program is inconsistent with the programming language of the stored procedure, the data cannot be stored. Summary of the invention
[0004] The embodiments of the present application provide a data storage method, apparatus, computer device, and computer-readable storage medium, which can improve the versatility of storage programs.
[0005] In a first aspect, an embodiment of the present application provides a data storage method, the data storage method comprising:
[0006] Get the running data generated by the application;
[0007] The operation data is converted to obtain target operation data; the language format of the target operation data matches the language format of the storage program corresponding to the application program;
[0008] The storage program is called to store the target operation data.
[0009] In a second aspect, an embodiment of the present application provides a data storage device, the data storage device comprising:
[0010] A first acquisition module is used to acquire the operation data generated by the application program;
[0011] A second acquisition module is used to convert the operation data to obtain target operation data; the language format of the target operation data matches the language format of the storage program corresponding to the application program;
[0012] A storage module is used to call the storage program to store the target operation data.
[0013] In a third aspect, an embodiment of the present application provides a computer device, comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps of the method described in the first aspect.
[0014] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0015] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method described in the first aspect.
[0016] The above-mentioned data storage method, device, computer equipment and computer-readable storage medium can convert the operating data generated by the application into target operating data by converting the operating data generated by the application, and the language format of the target operating data matches the language format of the storage program corresponding to the application. This avoids the problem that the language format of the storage program does not match the language format of the operating data and the operating data cannot be stored. The target operating data can be stored by calling the storage program corresponding to the application, thereby realizing the storage of operating data of different programming languages through the storage program corresponding to the application, and improving the versatility of the storage program. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 An application environment diagram of a data storage method in one embodiment;
[0019] Figure 2 is a flow chart of a data storage method in one embodiment;
[0020] Figure 3 is a flow chart of a data storage method in another embodiment;
[0021] Figure 4 A schematic diagram of converting an object in running data into a proxy object in one embodiment;
[0022] Figure 5 is a flow chart of a data storage method in another embodiment;
[0023] Figure 6 is a flow chart of a data storage method in another embodiment;
[0024] Figure 7is a flow chart of a data storage method in another embodiment;
[0025] Figure 8 is a structural block diagram of a data storage device in one embodiment;
[0026] Fig. 9 FIG. 4 is a structural block diagram of a data storage device in another embodiment. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0028] The data storage method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Figure 1 A computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 1 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data for the operation of the application. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a data storage method is implemented.
[0029] With the development of applications, users have an increasing demand for storage of application-related data. In order to ensure data persistence, data needs to be stored in a database. Usually, the programming language of the storage program is mostly C, and the application may be written in a different programming language, such as Java, JavaScript, Python, etc. Therefore, if the language formats of the storage program and the application programming language are different, the storage program will not be able to store the application's running data. Based on this, the present application proposes a data storage method to solve the problem that the storage program and the application programming language are inconsistent, resulting in the inability to store the running data generated by the application, so as to improve the versatility of the storage program.
[0030] In one embodiment, Figure 2 As shown, a data storage method is provided, which is applied to Figure 1 The computer device in the example is used to illustrate, including the following steps:
[0031] S201, obtaining operation data generated by the application.
[0032] The application program refers to a computer program that completes one or more specific tasks. By running the application program, interaction with the user can be achieved. Optionally, the application program in this embodiment can be a video application program, a music application program, or a shopping application program, etc., which is not limited in this embodiment. Optionally, the operation data generated by the application program in this embodiment can include text, pictures, audio, video and other data.
[0033] In this embodiment, the operation data can be acquired in real time during the operation of the application by calling the application programming interface (API) of the application during the operation of the application, or the operation data of the application can be acquired from the cache of the terminal or computer device after the operation of the application ends. Optionally, in this embodiment, the computer device can send an acquisition instruction to the terminal to acquire the operation data generated by the application, or the terminal can actively send the operation data generated by the application to the computer device.
[0034] It should be noted that with the development of computer technology, more and more programming languages have emerged, such as C, C++, Java, Python, JavaScript and other programming languages. These programming languages are used to write various different applications and can generate applications in different language formats. That is to say, the application in this embodiment may be an application written in one of the above-mentioned multiple programming languages. It can be understood that the programming language of the running data generated by the application corresponds to the programming language of the application. That is to say, the programming language of the running data generated by the application obtained in this embodiment may also be one of the above-mentioned multiple programming languages.
[0035] S202, converting the operation data to obtain target operation data; the language format of the target operation data matches the language format of the storage program corresponding to the application program.
[0036] Usually, in order to ensure the persistent use of the running data generated by the application, the running data generated by the application can be stored by calling the storage program corresponding to the application, where the storage program refers to a set of codes that stores the data to be stored by creating a storage function. However, there may be a problem that the programming language of the storage program corresponding to the application does not match the programming language of the application. For example, the programming language of the storage program is Java, and the programming language of the application is JavaScript. This will lead to the problem that the running data generated by the application cannot be stored through the storage program. Therefore, before storing the running data generated by the application, the running data generated by the application needs to be converted.
[0037] It is understandable that the language format of the operation data generated by the application is the same as the language format of the application. In order to match the language format of the stored program, the language format of the operation data can be converted into target operation data that matches the language format of the stored program. As an optional implementation, in order to be able to extend the conversion process of the operation data to any programming language that can support cross-language calls with the C language, the language format of the stored program can be C++, and the language format of the target operation data can be the same as the language format of the stored program, or can be a language format that can be mutually called with the language format of the stored program.
[0038] In this embodiment, a conversion method for converting the running data of the application can be determined according to the language format of the application and the language format of the storage program corresponding to the application, so that the running data generated by the application can be converted into the above-mentioned target running data through the conversion method. For example, according to the language format of the application and the language format of the storage program corresponding to the application, the running data generated by the application can be converted by using a calling function that can call each other between the language format of the storage program and the language format of the application, so as to convert the running data generated by the application into the above-mentioned target running data.
[0039] S203, calling a storage program to store the target operation data.
[0040] Optionally, in this embodiment, the target operation data can be stored according to a preset storage path by calling a storage program. Optionally, the target operation data can be stored in a memory of a computer device by calling a storage program, or the target operation data can be stored in a cloud server by calling a storage program.
[0041] In the above data storage method, by converting the running data generated by the application, the running data generated by the application can be converted into target running data, and the language format of the target running data matches the language format of the storage program corresponding to the application. This avoids the problem that the language format of the storage program does not match the language format of the running data and the running data cannot be stored. The target running data can be stored by calling the storage program corresponding to the application, thereby realizing the storage of running data of different programming languages through the storage program corresponding to the application, and improving the versatility of the storage program.
[0042] In the above scenario where the operation data is converted to obtain the target operation data, the operation data can be instantiated, converted and encoded to convert the operation data into the target operation data. Figure 3 As shown, the above S202 includes:
[0043] S301, instantiate the object in the running data and convert the object into a proxy object.
[0044] In object-oriented programming specifications, an object refers to a set of raw data including properties and behaviors obtained by instantiating a class. An object may include variables and functions, etc., and operations on the object can be achieved by accessing the properties of the object and calling the behavior of the object. In this embodiment, the object in the running data refers to the raw data including properties and behaviors obtained by instantiating a class in the running data.
[0045] It should be noted that in a programming language, a proxy for an object, i.e., a proxy object, can be created to intercept and customize access to and operations on an object. The real object can be accessed through the proxy object to achieve functional extension and protection of the object. The proxy object and the object can implement the same interface or inherit the same parent class attributes. It should be noted that the principles and methods for creating proxy objects are different in different programming languages. For different programming languages, objects in the running data can be instantiated differently to convert the objects into proxy objects. In this embodiment, as an optional implementation, a processing method for instantiating the running data can be determined based on the programming language of the running data, thereby instantiating the objects in the running data of the application and converting the objects in the running data into proxy objects.
[0046] As an optional implementation, the above S301 includes: generating storage instructions and access instructions corresponding to each field domain according to the field type of each field domain in the object, and obtaining a proxy object.
[0047] Among them, the field domain in the object refers to the variable in the object, which is used to store values. The field domain can be of different field types, for example, integer, floating point, character, Boolean, etc. It should be noted that in the embodiment of the present application, the operation performed is to store the running data in the database, then the operation performed on the running data can correspond to the storage operation and access operation on the running data. Therefore, in this embodiment, the method for instantiating the object in the running data can be to generate storage instructions and access instructions corresponding to each field domain in the object, and accordingly, the converted proxy object can include storage instructions and access instructions. For example, if the programming language of the application is Java language, then according to the field type of each field domain of the object in the Java language, the storage instructions and access instructions corresponding to each field domain can be generated to obtain the proxy object of the object.
[0048] In this embodiment, the class of the object to be proxied can be determined according to the object, and the proxy class code is generated and compiled in the compilation stage. The class of the proxy object is instantiated, that is, according to the field type of each field in the object, the storage instruction and access instruction corresponding to each field are generated respectively. Exemplarily, the schematic diagram of converting the object in the running data into a proxy object can be as follows: Figure 4 As shown, Figure 4 In the example, the object in the running data is instantiated, and the object obj includes three field domains, namely field1:int, field2:string, field3:[int]. That is, the first field domain is of integer type, the second field domain is of string type, and the third field domain is of integer array type. After the object is converted into a proxy object, the instructions corresponding to the first field domain in the proxy object are put_int(field1,v):func and get_int(field1,v):func, the instructions corresponding to the second field domain are put_string(field2,v):func and get_string(field2,v):func, and the instructions for the third field domain are put_array(field3,v):func and get_array(field3,v):func, where put represents a storage instruction and get represents an access instruction.
[0049] In this embodiment, since the storage instructions and access instructions corresponding to each field domain can be quickly and easily generated according to the field type of each field domain in the object, the proxy object can be quickly obtained, thereby improving the efficiency of converting the running data into the target running data according to the proxy object.
[0050] As another optional implementation, the application may be written in JavaScript programming language, and the above-mentioned running data also corresponds to JavaScript programming language. In this scenario, Figure 5 As shown, the above S301 includes:
[0051] S401, determining the attributes of the object.
[0052] Among them, the attributes of an object refer to the relevant information used to describe the object, and the attributes may include data types, member variables, variable names, access modifiers, etc. It should be noted that the attributes of the object can be assigned when the class is instantiated, that is, when the object is created. In this embodiment, the attribute accessor can be called to determine the attributes of the object through the get function defined in the attribute accessor. It should be noted that JavaScript language is a dynamically typed language. In JavaScript language, the attributes of an object can be dynamically modified, that is, during the compilation process, the attributes of an object in JavaScript language cannot be determined. Therefore, in this application, in order to convert the language format of the running data into a unified format, it is necessary to determine the attributes of the object in the running data.
[0053] S402, setting the attribute as a static attribute to obtain a proxy object.
[0054] Among them, static attributes refer to the data type of the variable in the object being a certain data type at compile time. In this embodiment, a setter can be called to set the attributes of the object through the set function defined in the setter, and the attributes of the object in the JavaScript language can be set as static attributes, thereby obtaining a dialing object. Exemplarily, the statement "object.setAttribute(`attribute`, `attribute value`)" can be used to set the attributes of the object.
[0055] In this embodiment, since the properties of an object can be determined simply and quickly by calling a property accessor, and the properties of the object can be set as static properties by setting it, a proxy object can be quickly obtained, thereby improving the efficiency of converting operation data into target operation data based on the proxy object.
[0056] S302: According to a preset conversion rule, the attribute information in the proxy object is converted to convert the proxy object into a general object.
[0057] Among them, the conversion rule refers to the rule for converting the properties of proxy objects in different programming languages into a unified format, and then the proxy object represented by the unified format is called a universal object. Among them, the attribute information of the proxy object may include the object name, data type, data storage format, etc. It should be noted that converting different programming languages into a universal representation format according to unified rules can achieve cross-language collaborative use within the conversion range. For example, in the JavaScript language, the data type int of the proxy object is converted to the universal representation format Gint. If the type of the proxy object is subsequently set to the str type, during the compilation process, it can be recognized that the universal representation format of the proxy object does not match and an error is reported. Therefore, by converting the attribute information of the proxy object into a universal representation format, the attributes of the proxy objects in different programming languages can be standardized.
[0058] In this embodiment, the representation format of the attribute information of the proxy object in different programming languages can be converted into a common representation format through a unified format conversion rule, and a common object can be generated according to the common representation format of the attribute information, thereby converting the proxy object into a common object. Exemplarily, the common representation forms corresponding to the attributes in different programming languages can be shown in Table 1, which lists the common representation formats corresponding to the object name, data type, data storage format, etc. in Java language and JavaScript.
[0059] Table 1
[0060] Java JavaScript Generic object representation format Class Object GObject int / Integer Number GNumber float Number GNumber Boolean Boolean GBoolean String String GString Object Any value GAny List <int> < / int> [Number] GList <gnumber> < / gnumber> Map<int,String> Map<Number,String> GMap<GNumber,GString>
[0061] S303, encoding the attribute information representing the proxy object in the general object to obtain target operation data.
[0062] Among them, encoding refers to a data conversion method that uses a coding symbol to represent a piece of information or a string of data. By encoding the data, the amount of data can be reduced and the efficiency and accuracy of data processing can be improved. In this embodiment, the attribute information can be encoded by data encoding to obtain the encoded attribute information, and the target operation data can be obtained according to the encoded attribute information. Among them, the data encoding method can be ASCII encoding, or it can also be icode encoding, or it can also be URL encoding, etc., which is not limited in this embodiment. In this embodiment, the attribute information representing the proxy object in the general object is information that converts the attributes of objects in different programming languages into attributes in a general representation format according to a general conversion rule. In this embodiment, by adopting a method of data encoding the attribute information, the attribute information representing the proxy object in the general object can be encoded into a format that can be recognized and stored by a computer, and the encoded data is determined as the target operation data.
[0063] The following takes an obj object in the Java language as an example to describe the process of converting an object into a proxy object and converting a proxy object into a general object. If the obj object contains three field domains, namely obj.field1=3, obj.field2=new string("str_demo"), and obj.field3=new array(4, 5, 6), then the storage instructions and access instructions corresponding to each field domain can be generated according to the field type of each field domain to obtain a proxy object, that is, the instructions corresponding to the first field domain are put_int(field1,3):func and get_int(field1,3):func, the instructions corresponding to the second field domain are put_string(field2,str_demo):func and get_string(field2,str_demo):func, and the instructions for the third field domain are put_array(field3,(4, 5, 6)):func and get_array(field3,(4, 5, 6)):func. According to the preset conversion rules, the attribute information of the above field domains is converted into a common representation format. For example, the int type in the first field domain is represented as the Gint type with a value of 3, and the string type in the second field domain is represented as the Gstring type with a value of st r_demo, represents the array type in the third field as a Gstring type with a value of {4, 5, 6}, and further converts the proxy object into a general object according to the general representation format.
[0064] In this embodiment, by instantiating the objects in the running data, the objects can be converted into proxy objects, so that the attribute information in the proxy objects can be converted according to the preset conversion rules to convert the proxy objects into universal objects. Since the expression methods for different programming languages in universal objects are consistent, the attribute information representing the proxy objects in the universal objects can be encoded to obtain target running data that matches the language format of the storage program, so that the running data generated by application programs written in different programming languages can be stored through the storage program, thereby improving the universality of the storage program.
[0065] In the above scenario of encoding the attribute information representing the proxy object in the general object to obtain the target operation data, the attribute information can be encoded according to key-value coding. In one embodiment, the above S303 includes: encoding the attribute information representing the proxy object in the general object according to key-value coding to obtain the target operation data.
[0066] Among them, key-value coding is a mechanism for accessing objects through string names. Using key-value coding, you can access the properties of an object without calling access methods and variable instances. Key-value coding includes value:forkey and setvalue:forkey. Among them, valueforkey is used to obtain the specified property name, and setvalueforkey is used to set the value of the specified property.
[0067] In this embodiment, the attribute information representing the proxy object in the general object can be encoded separately according to the key-value coding to obtain the object and the encoded values corresponding to each field domain contained in the object, so that the encoded values are determined as the target operation data. Exemplarily, if the general representation format of the field domain field1 in the object obj is: field1: {type: Gint, value: 3}, then the target operation data obtained after encoding the field domain according to the key-value coding is: key: obj, value: objGeneric@field1@GI; key: obj@field1, value: 3, the above key-value pair can be associated through the unique object identifier obj, wherein key: obj represents the identifier of the object after key-value coding, value: objGeneric@field1@GI represents the value corresponding to the field domain contained in the object after key-value coding, key: obj@field1 represents the identifier of the field domain contained in the object after key-value coding, and value: 3 represents the attribute value of the field domain after key-value coding.
[0068] Optionally, after encoding the attribute information, in order to facilitate the storage and reading of the encoded data, the key-value encoded data can be serialized and converted into binary format data. Figure 6 As shown, the above “encoding the attribute information representing the proxy object in the general object according to the key-value coding to obtain the target operation data” includes:
[0069] S501, encoding the attribute information according to the key-value coding to obtain an initial key-value pair group.
[0070] Among them, the initial key-value pair includes the identifier of the attribute and the value of the attribute. In this embodiment, the attribute information representing the proxy object in the general object can be encoded according to the key-value coding to obtain the initial key-value pair including the identifier and the value corresponding to each attribute information.
[0071] S502, serializing the initial key-value pair group through a data exchange format protocol, converting the initial key-value pair group into a binary format, and obtaining target operation data.
[0072] It is understandable that the formats of data processed in different development platforms or different computer devices may be different. In order to ensure that data can be exchanged between different development platforms or different computers, it is necessary to convert the data format into a unified representation format. Through the data exchange format protocol, data in different representation formats can be converted into a unified representation format. Optionally, the data exchange format protocol can be Google Protocol Buffer (Protobuf), or an extensible markup language protocol, or a JavaScript object notation protocol, which is not limited in this embodiment. In order to facilitate the storage and access of data, the data can be serialized, and all fields of the object can be converted into a form that can be stored or transmitted. Through serialization, the data that cannot be accessed in the object can be serialized, so that other programming languages can access all data of the object.
[0073] In this embodiment, the initial key-value pair can be serialized according to the data exchange format protocol, the key-value encoded data can be converted into binary format data, and the binary format data can be determined as the target running data. For example, if the initial key-value pair is: key:obj@field1, value:3, then the key-value pair can be serialized to obtain: key:obj@field1, value:01001110010011101100, where key:obj@field1 represents the field name of the field domain in the object, and value:01001110010011101100 represents the binary representation of the field value of the field domain. The serialized data can be stored in the memory through the storage engine to achieve persistent data storage, avoiding the problem of data loss caused by abnormal exit of the application or power failure of the device. Optionally, the storage engine can be a key-value storage engine, a transactional storage engine, or a levelDB storage engine, which is not limited in this embodiment.
[0074] Exemplarily, the storage and access process of the operating data is described below by taking the Java language format of the operating data as an example. Among them, the process of storing the running data includes: instantiating the objects in the running data, generating storage instructions and access instructions corresponding to each field domain according to the field type of each field domain in the object, converting the object into a proxy object, converting the attribute information in the proxy object according to the preset conversion rules, converting the proxy object into a general object, encoding the attribute information representing the proxy object in the general object according to the key-value encoding, obtaining an initial key-value pair group, serializing the initial key-value pair group through the data exchange format protocol, converting the initial key-value pair group into a binary format, obtaining the target running data, and saving the target running data into the memory through the key-value storage engine; the process of accessing the running data includes: selecting the data of an object from the memory, deserializing the object in the binary format to obtain the initial key-value pair group, decoding the initial key-value pair group, converting the initial key-value pair group into a general representation format, converting the general representation format of the object into a proxy object according to the above-mentioned preset conversion rules, and converting the proxy object into an object according to the inverse process of generating the proxy object in the JavaScript language, thereby representing the running data of the Java language in the Java Script language.
[0075] In this embodiment, the attribute information representing the proxy object in the general object can be encoded according to the key-value coding, and the attribute information representing the proxy object can be encoded into a form that is easy to store, thereby improving the efficiency of storing the obtained target operation data.
[0076] In the above scenario of converting the operation data to obtain the target operation data, the operation data can also be converted by calling a conversion program. In one embodiment, the above S202 includes: calling a target conversion program, converting the operation data by the target conversion program to obtain the target operation data.
[0077] It is understandable that, according to the processing requirements of the data, a program for converting and processing the operating data can be written in a programming language to convert the operating data into target operating data. In order to improve the efficiency of program writing, the program can be encapsulated as a function, and the encapsulated program is called a conversion program. Different programming languages can correspond to different conversion programs, and a conversion program with the same language format as the operating data can be determined as a target conversion program. That is, in this embodiment, according to the language format of the operating data, a corresponding target conversion program can be called from a preset conversion program library, and the operating data can be converted into target operating data by running the target conversion program.
[0078] Optionally, in this embodiment, conversion programs corresponding to different writing languages may be pre-assembled into a conversion program library, and in actual use, the target conversion program may be called from the preset conversion program library.
[0079] In this embodiment, by calling the target conversion program, the operating data can be converted and processed by the target conversion program to obtain target operating data. Since the process of calling the target conversion program is relatively simple, the target conversion program can be run quickly to obtain target operating data, thereby improving the efficiency of obtaining target operation.
[0080] After the operation data is converted into the target operation data, the target operation data can also be synchronized to other devices. Figure 7 As shown, the above method also includes:
[0081] S601, receiving a data synchronization request sent by a target device; the data synchronization request carries a synchronization protocol of the target device.
[0082] Among them, data synchronization refers to the process of establishing consistency between the stored data of the source device and the target device. Through data synchronization, the source data in the source device can be shared with the target device to maintain the integrity and uniformity of the data. Optionally, the target device can be a terminal, a server, or a computer device, which is not limited in this embodiment. The synchronization protocol in this embodiment refers to the rules for uniformly specifying the character sequence, operating frequency, time delay, etc. during data transmission. It should be noted that data synchronization can only be performed between the source device and the target device when the same synchronization protocol is satisfied.
[0083] In this embodiment, the data synchronization request sent by the target device may be received through the data transmission interface; or, the instruction carrying the data synchronization request sent by the target device may be received through the communication serial port.
[0084] S602: When the synchronization protocol is consistent with its own synchronization protocol, synchronize the target operation data to the target device.
[0085] In this embodiment, the received data synchronization request can be parsed to obtain the synchronization protocol of the target device, and the above synchronization protocol can be compared with its own synchronization protocol. When the two are consistent, the target operation data can be synchronized to the target device through the data transmission interface.
[0086] In this embodiment, by receiving a synchronization request sent by the target device carrying the synchronization protocol data of the target device, the target operation data can be synchronized to the target device when the synchronization protocol is consistent with its own synchronization protocol, thereby enabling synchronization of the operation data between different devices.
[0087] To facilitate understanding by those skilled in the art, the data storage method provided by the present application is described in detail below. The method may include:
[0088] S1, obtain the operation data generated by the application.
[0089] S2, for applications written in Java language, calls the target conversion program that matches the language format of Java language from the preset conversion program library, and generates storage instructions and access instructions corresponding to each field domain according to the field type of each field domain in the object in the running data through the called target conversion program to obtain the proxy object.
[0090] S3, for applications written in JavaScript language, calls a target conversion program that matches the language format of JavaScript language from a preset conversion program library, determines the properties of objects in the running data through the called target conversion program, sets the determined properties as static properties, and obtains a proxy object.
[0091] S4, converting the attributes in the proxy object according to a preset conversion rule, and converting the proxy object into a general object.
[0092] S5, encoding the attribute information representing the proxy object in the general object according to the key-value coding to obtain an initial key-value pair group.
[0093] S6, serializing the initial key-value pair group through the data exchange format protocol, converting the initial key-value pair group into a binary format, and obtaining the target operation data.
[0094] S7, calling the storage program to store the target operation data.
[0095] S8, receiving a synchronization request sent by the target device and carrying synchronization protocol data of the target device.
[0096] S9, when the synchronization protocol is consistent with its own synchronization protocol, synchronize the target operation data to the target device.
[0097] It should be noted that for the descriptions in the above S1-S9, reference may be made to the relevant descriptions in the above embodiments, and the effects are similar, so this embodiment will not be repeated here.
[0098] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0099] Based on the same inventive concept, the embodiment of the present application also provides a data storage device for implementing the data storage method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more data storage device embodiments provided below can refer to the limitations on the data storage method above, and will not be repeated here.
[0100] In one embodiment, Figure 8 As shown, a data storage device is provided, comprising: a first acquisition module 10, a second acquisition module 11 and a storage module 12, wherein:
[0101] The first acquisition module 10 is used to acquire the operation data generated by the application.
[0102] The second acquisition module 11 is used to convert the operation data to obtain target operation data; the language format of the target operation data matches the language format of the storage program corresponding to the application program.
[0103] The storage module 12 is used to call the storage program to store the target operation data.
[0104] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0105] In one embodiment, Fig. 9 As shown, the second acquisition module 11 includes: a first conversion unit 111, a second conversion unit 112 and a first acquisition unit 113, wherein:
[0106] The first conversion unit 111 is used to instantiate the objects in the running data and convert the objects into proxy objects.
[0107] The second conversion unit 112 is used to convert the attribute information in the proxy object according to a preset conversion rule, and convert the proxy object into a general object.
[0108] The first acquisition unit 113 is used to encode the attribute information representing the proxy object in the general object to obtain the target operation data.
[0109] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0110] In one embodiment, please continue to refer to Fig. 9 The first conversion unit 111 is specifically used to generate storage instructions and access instructions corresponding to each field domain according to the field type of each field domain in the object to obtain a proxy object.
[0111] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0112] In one embodiment, please continue to refer to Fig. 9 The first conversion unit 111 is specifically used to: determine the attributes of the object; set the attributes as static attributes to obtain a proxy object.
[0113] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0114] In one embodiment, please continue to refer to Fig. 9 The first acquisition unit 113 is specifically used to encode the attribute information representing the proxy object in the general object according to the key-value coding to obtain the target operation data.
[0115] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0116] In one embodiment, please continue to refer to Fig. 9 The first acquisition unit 113 is further specifically used to: encode the attribute information according to the key-value coding to obtain an initial key-value pair; serialize the initial key-value pair through the data exchange format protocol, convert the initial key-value pair into a binary format, and obtain the target operation data.
[0117] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0118] In one embodiment, please continue to refer to Fig. 9The second acquisition module 11 further includes: a second acquisition unit 114, wherein:
[0119] The second acquisition unit 114 is used to call the target conversion program, and convert the operating data through the target conversion program to obtain the target operating data. The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0120] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0121] In one embodiment, please continue to refer to Fig. 9 The above device further includes: a calling module 13, wherein:
[0122] The calling module 13 is used to call the target conversion program from a preset conversion program library; wherein the conversion program library includes conversion programs corresponding to different writing languages.
[0123] The data storage device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effects are similar, which will not be repeated here.
[0124] In one embodiment, please continue to refer to Fig. 9 The above device further includes: a receiving module 14 and a synchronization module 15, wherein:
[0125] The receiving module 14 is used to receive a data synchronization request sent by a target device; the data synchronization request carries a synchronization protocol of the target device.
[0126] The synchronization module 15 is used to synchronize the target operation data to the target device when the synchronization protocol is consistent with its own synchronization protocol.
[0127] Each module in the above data storage device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0128] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0129] Get the running data generated by the application;
[0130] The operation data is converted to obtain target operation data; the language format of the target operation data matches the language format of the storage program corresponding to the application program;
[0131] Call the storage program to store the target running data.
[0132] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0133] Instantiate the objects in the running data and convert them into proxy objects;
[0134] According to the preset conversion rules, the attribute information in the proxy object is converted to the general object;
[0135] The attribute information representing the proxy object in the general object is encoded to obtain the target operation data.
[0136] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0137] According to the field type of each field domain in the object, storage instructions and access instructions corresponding to each field domain are generated to obtain a proxy object.
[0138] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0139] Determine the properties of an object;
[0140] Set the property as a static property to get the proxy object.
[0141] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0142] According to the key-value coding, the attribute information representing the proxy object in the general object is encoded to obtain the target operation data.
[0143] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0144] According to the key-value coding, the attribute information is encoded to obtain an initial key-value pair;
[0145] The initial key-value pair is serialized through a data exchange format protocol, and the initial key-value pair is converted into a binary format to obtain target operation data.
[0146] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0147] The target conversion program is called, and the operation data is converted and processed by the target conversion program to obtain target operation data.
[0148] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0149] The target conversion program is called from a preset conversion program library; wherein the conversion program library includes conversion programs corresponding to different writing languages.
[0150] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0151] Receiving a data synchronization request sent by a target device; the data synchronization request carries a synchronization protocol of the target device;
[0152] When the synchronization protocol is consistent with its own synchronization protocol, the target operation data is synchronized to the target device.
[0153] The embodiment of the present application also provides a computer-readable storage medium. One or more non-volatile computer-readable storage media containing computer-executable instructions, when the computer-executable instructions are executed by one or more processors, the processors execute the steps of the data storage method.
[0154] An embodiment of the present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the data storage method.
[0155] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0156] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0157] The technical features of the above embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0158] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A data storage method, characterized in that: include: Get the running data generated by the application; Converting the operating data to obtain target operating data; The language format of the target running data matches the language format of the storage program corresponding to the application program; The storage program is called to store the target operation data.
2. The method according to claim 1, characterized in that The converting and processing the operation data to obtain target operation data includes: Instantiating the objects in the running data and converting the objects into proxy objects; According to a preset conversion rule, the attribute information in the proxy object is converted to a general object; The attribute information representing the proxy object in the general object is encoded to obtain the target operation data.
3. The method according to claim 2, characterized in that The instantiating the object in the running data to convert the object into a proxy object includes: According to the field type of each field domain in the object, storage instructions and access instructions corresponding to each field domain are generated to obtain the proxy object.
4. The method according to claim 2, characterized in that: The instantiating the object in the running data to convert the object into a proxy object includes: determining properties of the object; The attribute is set as a static attribute to obtain the proxy object.
5. The method according to claim 2, characterized in that: The encoding of the attribute information representing the proxy object in the general object to obtain the target operation data includes: According to the key-value coding, the attribute information representing the proxy object in the general object is encoded to obtain the target operation data.
6. The method according to claim 5, characterized in that The step of encoding the attribute information representing the proxy object in the general object according to the key-value coding to obtain the target operation data includes: Encoding the attribute information according to the key-value coding to obtain an initial key-value pair group; The initial key-value pair group is serialized through a data exchange format protocol, and the initial key-value pair group is converted into a binary format to obtain the target operation data.
7. The method according to any one of claims 1 to 6, characterized in that: The converting and processing the operation data to obtain target operation data includes: The target conversion program is called, and the operation data is converted by the target conversion program to obtain target operation data.
8. The method according to claim 7, characterized in that The method further comprises: The target conversion program is called from a preset conversion program library; wherein the conversion program library includes conversion programs corresponding to different writing languages.
9. The method according to claim 1, characterized in that: The method further comprises: Receiving a data synchronization request sent by a target device; the data synchronization request carries a synchronization protocol of the target device; When the synchronization protocol is consistent with its own synchronization protocol, the target operation data is synchronized to the target device.
10. A data storage device, characterized in that: include: A first acquisition module is used to acquire the operation data generated by the application program; A second acquisition module is used to convert the operation data to obtain target operation data; The language format of the target running data matches the language format of the storage program corresponding to the application program; A storage module is used to call the storage program to store the target operation data.
11. A computer device comprising a memory and a processor, wherein a computer program is stored in the memory, wherein: When the computer program is executed by the processor, the processor is caused to perform the steps of the method for determining the charging current according to any one of claims 1 to 9.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.
13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.