Data processing method and device, equipment, medium and program product
By automatically generating code snippets corresponding to business data and performing compilation and linking, the problems of low compile-time constant replacement efficiency and poor reliability in the existing technology are solved, and efficient and reliable executable file generation is achieved.
Patent Information
- Application Number
- CN202310391561.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-03
- Publication Date
- 2024-10-15
AI Technical Summary
In the existing technology, programmers need to manually replace compile-time constants in business codes with specific values, resulting in low efficiency and low reliability of binary file generation, and prone to substitution errors or missing variables.
Use an automated method to generate code snippets corresponding to business data, compile and link the code snippets with the business code, and generate an executable file.
The efficiency and reliability of executable file generation are improved, the automated process is faster and more accurate, and the possibility of manual errors is reduced.
Smart Images

Figure CN118778965A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a data processing method, apparatus, device, medium and program product. Background Art
[0002] At present, there are many businesses involved in various fields, such as payment business, evaluation business, etc. And each business is implemented through the corresponding business code.
[0003] In the related art, programmers need to replace compile-time constants in business codes with corresponding business data, that is, replace compile-time constants with specific values. Further, the compiler compiles the business code to form an executable file. This data processing method requires manual replacement of compile-time constants, that is, programmers need to replace compile-time constants in business codes with corresponding business data one by one.
[0004] On the one hand, this method has the problem of low efficiency in binary file generation; on the other hand, since this method is prone to compile-time variable replacement errors or some compile-time variables being omitted, this method has low reliability. Summary of the invention
[0005] The present application provides a data processing method, apparatus, device, medium and program product. On the one hand, the data processing method can improve the efficiency of generating executable files; on the other hand, the data processing method has higher reliability.
[0006] In a first aspect, an embodiment of the present application provides a data processing method, comprising: generating a code snippet corresponding to the business data based on the business data and a data model corresponding to the business data; and compiling and linking the business code and the code snippet to obtain an executable file.
[0007] In a second aspect, an embodiment of the present application provides a data processing device, comprising: a generation module and a compilation and linking module, wherein the generation module is used to generate code snippets corresponding to the business data based on the business data and the data model corresponding to the business data; the compilation and linking module is used to compile and link the business code and the code snippet to obtain an executable file.
[0008] In some implementations, the device further includes: a determination module and an initialization module, wherein the determination module is used to determine a target business variable in an executable file; and the initialization module is used to treat the target business variable as a global variable or a static variable and initialize the target business variable.
[0009] In some implementations, the initialization module is specifically used to: when the target business variable is used for the first time during the running of the executable file, use the target business variable as a static variable and initialize the target business variable.
[0010] In some implementations, the initialization module is specifically used to: before executing the executable file, take the target business variable as a global variable and initialize the target business variable.
[0011] In some implementations, the generation module is specifically used to: generate code snippets for the data model and business data through a code generator.
[0012] In some implementations, the generation module is further used to: after the code snippet is generated for the data model and the business data by the code generator, if at least one of the code generator, the data model and the business data is updated, then regenerate the code snippet.
[0013] In some implementations, the compile and link module is further used to: after the business code and the code snippet are compiled and linked to obtain the executable file, if at least one of the business code and the code snippet is updated, regenerate the executable file.
[0014] In some possible implementations, the device also includes: an acquisition module, used to acquire a build file; the build file is used to describe a first generation rule for code snippets, a second generation rule for executable files, a first dependency relationship between data models and business data, and a second dependency relationship between business codes and code snippets; accordingly, the generation module is specifically used to: generate code snippets from data models and business data based on the first generation rule and the first dependency relationship; the compilation and linking module is specifically used to: compile and link business codes and code snippets based on the second generation rule and the second dependency relationship to obtain an executable file.
[0015] In some possible implementations, the device also includes: a detection module, which is used to detect the legality and integrity of the business data based on the data model before the generation module generates code snippets from the data model and the business data based on the first generation rule and the first dependency relationship; accordingly, the generation module is specifically used to: if the business data is detected to be legal and complete, then generate code snippets from the data model and the business data based on the first generation rule and the first dependency relationship.
[0016] In some possible implementations, the detection module is specifically used to detect whether the length and type of the business data conform to the length and type specified by the data model.
[0017] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program, the processor being used to call and run the computer program stored in the memory, and executing the method in the first aspect or its various implementations.
[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium for storing a computer program, wherein the computer program enables a computer to execute the method in the first aspect or its various implementations.
[0019] In a fifth aspect, an embodiment of the present application provides a computer program product, comprising computer program instructions, which enable a computer to execute a method as in the first aspect or its various implementations.
[0020] In a sixth aspect, an embodiment of the present application provides a computer program, which enables a computer to execute the method in the first aspect or its various implementations.
[0021] Through the technical solution provided in the embodiment of the present application, the present application uses an automated method to generate a code snippet corresponding to the business data, and then compiles and links the code snippet and the business code to obtain an executable file. Since the automated method is faster and more accurate than the manual method of replacing the numerical values of compile-time constants, based on this, on the one hand, the data processing method can improve the efficiency of generating executable files; on the other hand, the data processing method has higher reliability. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0023] Figure 1 An application scenario diagram provided for an embodiment of the present application;
[0024] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;
[0025] Figure 3 A schematic diagram of a business data processing method provided in an embodiment of the present application;
[0026] Figure 4 A schematic diagram of a data processing device 400 provided in an embodiment of the present application;
[0027] Figure 5 It is a schematic block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or server that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0030] Before introducing the technical solution of the present application, the following first describes the relevant knowledge involved in the embodiments of the present application:
[0031] 1. Build Tool: A build tool is a tool used to automatically build software projects. It can manage processes such as code compilation, resource packaging, test running, document generation, and can automatically detect and handle dependencies, thereby improving the efficiency and reliability of software development. Build tools are an indispensable part of software development and can greatly improve development efficiency and project reliability. Choosing a suitable build tool should be evaluated and selected based on the needs and technology stack of the specific project.
[0032] 2. Runtime Constant: A runtime constant is a value that does not change during the program's execution. Unlike compile-time constants, the value of a runtime constant cannot be determined at compile time, but only when the program is running. It should be noted that, unlike compile-time constants, the value of a runtime constant is determined at runtime, so for complex expressions or function calls, it may affect the performance of the program.
[0033] 3. Compile-time constant refers to a constant whose value can be determined at compile time. Compile-time constants will be replaced with their specific values at compile time and do not need to be calculated at runtime. Using compile-time constants in a program can bring multiple benefits. First, it can improve the execution efficiency of the program because the compiler can replace the value of the constant with its specific value at compile time, thus avoiding calculations at runtime. Secondly, it can improve the maintainability and readability of the program because the use of constants can make the code clearer and easier to understand. Finally, it can avoid errors caused by changes in constant values at runtime. Among them, compile-time constants are also called public static final variables.
[0034] 4. Compilation and linking, including four stages: preprocessing (precompilation), compilation, assembly, and linking.
[0035] 1. Preprocessing (precompilation)
[0036] The precompilation process turns the source file into a .i file, mainly processing precompilation instructions starting with #, such as #include, #define, etc.
[0037] The main processing rules include:
[0038] Delete all "#define" and expand all macro definitions;
[0039] Process all conditional precompilation directives, such as "#if", "#ifdef", "#elif", "#else", "#endif";
[0040] Process the "#include" precompilation directive and insert the included file into the location of the precompilation directive;
[0041] Delete all comments " / / " and " / ** / ";
[0042] Add line number and file name identifiers so that the compiler can generate line number information for debugging during compilation and display line numbers when compilation errors or warnings are generated during compilation;
[0043] Preserve all #pragma compiler directives.
[0044] 2. Compile
[0045] Compilation is to perform a series of lexical analysis, syntax analysis, semantic analysis, and optimization on the preprocessed file to generate the corresponding assembly code file .s.
[0046] 3. Assembly
[0047] The assembler turns assembly code into machine instructions. It has no complex syntax, no semantics, and no need for optimization. It only requires one-to-one translation and finally generates the target file, .obj in Windows and .o in Linux.
[0048] 4. Links
[0049] The linking process links the .o file and the .a library file together to generate a binary executable file.
[0050] The linking process mainly includes address and space allocation, symbol resolution (symbol binding / address binding), relocation, etc.
[0051] Among them, each module is compiled separately, and the process of linking them after compilation is completed is called static linking. During compilation, the addresses of each symbol of other modules are unknown, and they are temporarily written as 0. A relocation entry will be left here. During linking, after each symbol has an address, the address of each symbol in each module is refreshed to the correct value. This process is called relocation. Among them, dynamic link library: .dll in Windows, .so in Linux. Static link library: .lib in Windows, .a in Linux.
[0052] 5. Protocol Buffer (protobuf) is a mixed language data standard within a certain enterprise. It serializes structured data and is used in communication protocols, data storage and other fields as a language-independent, platform-independent, and extensible serialized structured data format.
[0053] 1. protobuf usually includes the following three points:
[0054] (1) A binary data exchange format that can convert the contents of storage classes defined in C++ into binary sequence strings and vice versa, mainly used for data transmission or storage;
[0055] (2) A source file with a .proto extension is defined. This source file can be used to define the content of the storage class;
[0056] (3) protobuf has its own compiler protoc, which can compile .proto into .cc file, making it a class that can be directly used in C++ projects.
[0057] 2. A message body is defined in protobuf, also known as a message type, which is specified by the keyword message field, which is similar to the class keyword in C++ / Java. After proto is compiled into C++ code using the protobuf compiler, each message will generate a C++ class with the corresponding name.
[0058] Explanation of the fields in the message:
[0059] required: A required field in the message. Failure to set this field will result in encoding and decoding exceptions.
[0060] optional: An optional field in the message. The default value can be set using the default keyword.
[0061] repeated: A field that can be repeated in a message.
[0062] Field types in a message include, but are not limited to: Boolean (bool), integer (int32) with a length of 32, single floating point (float), double floating point (double), and string (string). Messages can also be nested, that is, a message includes fields of the message type.
[0063] 3. Compile .proto files
[0064] The compiler protoc can execute the following protoc command to compile the .proto file and generate the corresponding .c file:
[0065] protoc -I=$SRC_DIR
[0066] --cpp_out=$DST_DIR xxx.proto
[0067] Among them, $SRC_DIR represents the source directory where proto is located;
[0068] --cpp_out means generating C++ code;
[0069] $DST_DIR indicates the target directory for generating code;
[0070] xxx.proto indicates which proto file the interface is generated for, for example, tutorial.person.proto;
[0071] After the compiler protoc completes the compilation, two files will be generated: tutorial.pb.h and tutorial.pb.cc, where tutorial represents the file name and pb is the abbreviation of protobuf.
[0072] In addition, the compiler protoc generates a set of accessor methods for each field of the message defined in the .proto file:
[0073] For example, set() is used to set a value for a field, and get() is used to implement a function call.
[0074] 6. Yet Another Markup Language (YAML), which mainly emphasizes that this language is data-centric rather than tag-centric, while languages like Extensible Markup Language (XML) use a large number of tags.
[0075] YAML is highly readable and easy to understand, and is used to express the format of data serialization. Its syntax is similar to other high-level languages, and it can also simply express data forms such as arrays, hash tables, and scalars. It uses whitespace symbols for indentation and relies heavily on appearance, making it particularly suitable for expressing or editing data structures and various configuration files. The YAML configuration file suffix is .yaml, such as application.yaml.
[0076] 7. JavaScript Object Notation (JSON) is a lightweight data exchange language based on human-readable text and used to transmit data objects consisting of attribute values or sequential values. Although JSON is a subset of JavaScript, it is a language-independent text format and adopts some conventions similar to the C language family.
[0077] The basic data types of JSON include: numeric type (which does not distinguish between integers and floating-point types), string, Boolean type, ordered list of values, object, and null type.
[0078] 8. Json Schema, which defines a set of vocabulary and rules, which are used to define JSON metadata, and metadata is also expressed in the form of JSON data. JSON metadata defines the specifications that JSON data needs to meet, including members, structures, types, constraints, etc.
[0079] 9. Document Type Definition (DTD) is a set of grammatical rules about tags established for data exchange between programs. It is part of the Standard Generalized Markup Language (SGML) and XML 1.0 specifications. Documents can verify whether the format complies with this rule according to certain DTD grammatical rules. Document type definitions can also be used to ensure the legality of the document format of Standard Generalized Markup Language and Extensible Markup Language. By comparing documents with document type definition files, you can check whether the documents comply with the specifications and whether the elements and tags are used correctly. File instances provide applications with a format for data exchange. In short, DTD is used to constrain XML documents so that they can be used under certain specifications.
[0080] 10. An INI file is a message configuration document for a computer program that contains public keys for characteristics and sections that organize properties in a framework and syntax.
[0081] 11. Microservices is an architecture that divides a single monolithic application into smaller projects and related independent services. A service usually implements a set of independent features or functions, including its own business logic and adapters. The association between each microservice is achieved through the Application Programming Interface (API). These independent microservices do not need to be deployed in the same virtual machine, the same system, and the same application server.
[0082] 12. Grayscale release, also known as canary release, refers to a release method that can smoothly transition between black and white. A / B testing can be performed on it, that is, some users continue to use product feature A, and some users start using product feature B. If users have no objection to B, then gradually expand the scope and migrate all users to B. Grayscale release can ensure the stability of the overall system. Problems can be discovered and adjusted during the initial grayscale to ensure their impact.
[0083] The following is a description of the technical problems, inventive concepts and application scenarios to be solved by the technical solution of this application:
[0084] In the related art, programmers need to replace compile-time constants in business codes with corresponding business data, that is, replace compile-time constants with specific values, for example, the compile-time constant person.age is replaced with 30. Further, the compiler compiles the business code to form an executable file. This data processing method requires manual numerical replacement of compile-time constants, that is, programmers are required to replace the compile-time constants in the business code with corresponding business data one by one. On the one hand, this method has the problem of low efficiency in binary file generation; on the other hand, since this method is prone to compile-time variable replacement errors or some compile-time variables are omitted, this method has low reliability.
[0085] In order to solve the above technical problems, the embodiment of the present application proposes to generate a code snippet corresponding to the business data in an automated manner, and then compile and link the code snippet and the business code to obtain an executable file. The executable file may be an executable binary file, but is not limited thereto.
[0086] The embodiments of the present application can be applied to Figure 1 The application scenarios shown in the figure are, but not limited to:
[0087] For example, Figure 1 An application scenario diagram provided for an embodiment of the present application, such as Figure 1 As shown, a construction tool may be installed on the electronic device 100. The construction tool is a tool for automatically constructing software projects. The electronic device 100 may implement the data processing method provided in the embodiment of the present application through the construction tool.
[0088] In some implementations, the electronic device may be a terminal device or a server, etc., but is not limited thereto.
[0089] In some implementations, the terminal device may be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto.
[0090] In some possible implementations, in the embodiments of the present application, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms.
[0091] In some implementations, the electronic device 100 may obtain the business data input by the user, or the electronic device 100 may be connected to other devices in a wireless or wired manner to obtain the business data from the other devices.
[0092] The technical solution of this application is described in detail below:
[0093] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application, the method can be executed by an electronic device, and the electronic device can be a terminal device or a server, etc., but is not limited thereto. The terminal device can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, etc., but is not limited thereto. The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, as well as big data and artificial intelligence platforms. Figure 2 As shown, the method may include:
[0094] S210: Generate a code snippet corresponding to the business data based on the business data and a data model corresponding to the business data;
[0095] S220: Compile and link the business code and the code snippet to obtain an executable file.
[0096] The following is a detailed description of S210:
[0097] In some possible implementations, the data model includes: business field names corresponding to the business data and data types corresponding to these business fields.
[0098] In some implementations, the description language used by the data model may be protobuf, JSONSchema, DTD, etc., but is not limited thereto.
[0099] For example, suppose the description language used by the data model is protobuf, and protobuf defines the message body. Each message is a small logical record of information, containing a series of field names and value pairs. The above data model can be a message. The following example illustrates the message:
[0100] For example, the compiler generates the following message:
[0101]
[0102] It should be understood that the value corresponding to each business field included in each message is the unique number corresponding to the business field in the message. For example, the unique number corresponding to the business field name in the message Person is 1.
[0103] It should be understood that each message may also nest other messages, for example, the message AddressBook nests the message Person, and the message Person nests the message PhoneNumber.
[0104] It should be understood that each message includes: business field names corresponding to business data and data types corresponding to these business fields. For example, assuming that the above data model is message AddressBook, the business field names it includes include: people, and its data type is repeated Person, indicating a repeatable Person type.
[0105] In some implementations, the format of the business data may be in YAML format, JSON format, INI format, etc., but is not limited thereto.
[0106] In some implementations, the business data includes: at least one business field name and a numerical value corresponding to each business field name.
[0107] The following takes the business data AddressBook as an example:
[0108]
[0109]
[0110] It can be seen from this example and the above example of message AddressBook that the business fields included in the data model messageAddressBook are consistent with the business data.
[0111] In some implementations, the code snippet corresponding to the business data may be a C++ code snippet, but is not limited thereto.
[0112] In some implementations, the electronic device may generate a code snippet corresponding to the business data through a code generator.
[0113] It should be understood that the code generator is also referred to as a data code generator, but is not limited thereto.
[0114] In some implementations, the code generator may be a code generator in software form.
[0115] In some possible implementations, the code generator may be embedded in a construction tool or may be independent of the construction tool, which is not limited in the embodiments of the present application.
[0116] It should be understood that if the description language used in the above data model is protobuf, then the code generator can use the get() and set() encapsulated in protobuf to implement function calls and field assignment functions respectively.
[0117] Following the example of the above data model message AddressBook and the corresponding business data, the following example illustrates the above code snippet:
[0118]
[0119]
[0120] The following is a detailed description of S220:
[0121] It should be understood that the business code is the logic code for implementing the business, based on this, the business code is also called logic code or business logic code.
[0122] The following is an example to illustrate the business code:
[0123]
[0124] In some implementations, the business data processing method can be divided into two stages, namely, a development stage and a construction stage. The data processing method provided in the embodiment of the present application can be applied to the construction stage, which is explained below by an example:
[0125] For example, Figure 3 A schematic diagram of a business data processing method provided in an embodiment of the present application, such as Figure 3As shown, the business data processing method includes two stages, namely: the development stage and the construction stage. In the development stage, programmers can design data models, write business codes, and construct business data. The construction stage is an automated stage, including: automatic compilation using a construction tool, that is, executing the above data processing method through a construction tool, including: generating code snippets corresponding to the business data based on the business data and the data model corresponding to the business data; compiling and linking the business code and the code snippets to obtain an executable file. Furthermore, the construction stage also includes: building a release image, that is, constructing a release image of the executable file. Furthermore, the construction stage also includes: service launch, that is, launching the release image of the executable file.
[0126] It should be understood that the embodiments of the present application do not limit the execution order of designing data models, writing business codes, and constructing business data involved in the development phase.
[0127] In some possible implementations, the embodiments of the present application can launch services through grayscale release, and it is necessary to ensure the idempotence of the results returned by the same request before and after the grayscale release. In other words, before and after the grayscale release, assuming that the business data is the same, it is necessary to ensure that the business results achieved based on the business data remain consistent.
[0128] In some implementations, after the service is launched, the electronic device may also perform a debugging process, wherein the service data used in the debugging process may be simulated data, mainly used to test the service code. After the service is launched, real service data needs to be used.
[0129] In summary, the embodiment of the present application provides a data processing method, in which an electronic device can generate a code snippet corresponding to business data in an automated manner, and then compile and link the code snippet and the business code to obtain an executable file. Since the automated method is faster and more accurate than the manual method of replacing the numerical values of compile-time constants, based on this, on the one hand, the data processing method can improve the efficiency of generating executable files; on the other hand, the data processing method has higher reliability.
[0130] It should be understood that, usually during the running stage of the executable file, the electronic device can initialize the business variables involved, that is, assign values to the business variables, and a business variable may appear in multiple places in the executable file. If the business variable needs to be initialized once each time the executable file is run, the running efficiency of the executable file is low. Based on this, in order to solve this technical problem, the embodiment of the present application also proposes to use the business variable as a global variable or a static variable, so that the business variable can be initialized once, as follows:
[0131] In some implementations, the electronic device may determine a target business variable in an executable file; use the target business variable as a global variable or a static variable, and initialize the target business variable.
[0132] In some implementations, each business variable in the executable file may correspond to the business data or a business field in the above data model. For example, the business variable phone.type corresponds to the phone type field in the business data.
[0133] The electronic device may determine the target service variable in the executable file in any of the following achievable ways, but is not limited thereto:
[0134] In a first implementation mode, the target business variable can be any business variable in the executable file. For example, for the above business code tutorial.person.main.cpp, the business variables name, id, email, PhoneType, number, etc. in the corresponding executable file can all be used as target business variables.
[0135] In a second implementation method, the target business variable may be a business variable in the executable file whose usage frequency is greater than a preset frequency. The preset frequency may be 2, 3, etc., but is not limited thereto. For example, for the above business code tutorial.person.main.cpp, the usage frequency of the business variable PhoneType in the corresponding executable file is 3, which is greater than the preset frequency 2. Based on this, the business variable PhoneType may be used as the target business variable.
[0136] In some implementations, the electronic device can scan the executable file and initialize the usage frequency of each business variable in the executable file to 0. For any business variable in the executable file, each time the business variable is scanned, the usage frequency of the business variable is increased by one until the electronic device completes scanning the executable file.
[0137] In other possible implementations, the electronic device may input the executable file into the first model to obtain business variables in the executable file whose usage frequency is greater than a preset frequency. Finally, the electronic device may use these business variables whose usage frequency is greater than the preset frequency as target business variables.
[0138] It should be understood that the first model can be understood as a classification model, which can divide all business variables in the executable file into two categories, namely business variables with a usage frequency greater than a preset frequency, and business variables with a usage frequency less than or equal to the preset frequency.
[0139] For example, for the above-mentioned business code tutorial.person.main.cpp, assuming that the business variables in its corresponding executable file include: name, id, email, PhoneType, number, after the executable file is input into the first model, its output is PhoneType, number, based on this, the electronic device can set the business variables PhoneType and number as target business variables.
[0140] In some implementations, the first model may be a neural network model, but is not limited thereto.
[0141] In some implementations, the training device may perform supervised training or unsupervised training on the first model through training samples. When the supervised training method is adopted, each training sample may include: an executable file and a business variable in the executable file whose usage frequency is greater than a preset frequency as label data. When the unsupervised training method is adopted, each training sample may include: an executable file.
[0142] In the training phase of the first model, the electronic device can calculate the training loss. Further, the electronic device can minimize the loss to adjust the parameters of the first model until the loss converges or the number of training times reaches a preset number.
[0143] In some implementations, the loss may be a cross entropy loss, a one-norm (L1) loss, a mean square error loss (MSE), etc., but is not limited thereto.
[0144] In a third implementation method, the electronic device may input the executable file into the second model to obtain the importance of each business variable in the executable file. Finally, the electronic device may use the business variable whose importance is greater than a preset threshold as the target business variable.
[0145] For example, for the above business code tutorial.person.main.cpp, assuming that the business variables in the corresponding executable file include: name, id, email, PhoneType, number, after the executable file is input into the second model, the importance of the input name, id, email, PhoneType, number is 0.1, 0.1, 0.2, 0.4, 0.4 respectively, and assuming that the preset threshold corresponding to the importance is 0.3. Then the electronic device determines that the PhoneType and number business variables are the target business variables.
[0146] In some possible implementations, for any business variable, the importance of the business variable is proportional to the frequency of use of the business variable in the executable file. In other words, the higher the frequency of use of the business variable, the greater the importance of the business variable; conversely, the lower the frequency of use of the business variable, the smaller the importance of the business variable.
[0147] In some implementations, the second model may be a neural network model, but is not limited thereto.
[0148] In some implementations, the training device may perform supervised training or unsupervised training on the second model through training samples. When supervised training is used, each training sample may include: an executable file and the importance of each business variable in the executable file. When unsupervised training is used, each training sample may include: an executable file.
[0149] In the training phase of the second model, the electronic device can calculate the training loss. Further, the electronic device can minimize the loss to adjust the parameters of the second model until the loss converges or the number of training times reaches a preset number.
[0150] In some implementations, the loss may be a cross entropy loss, a one-norm (L1) loss, a MSE, etc., but is not limited thereto.
[0151] In some implementations, the electronic device may use the target business variable as a static variable and initialize the target business variable when the target business variable is used for the first time during the execution of the executable file.
[0152] For example, assuming that the main function includes multiple business codes, when the target business variable is used for the first time in the main function, the target business variable can be used as a static variable and initialized. When the target business variable is subsequently used in other business codes, the initialization data corresponding to the target business variable can be used.
[0153] In other possible implementations, the electronic device may use the target business variable as a global variable and initialize the target business variable before executing the executable file.
[0154] For example, the target business variable can be defined as a global variable before the main function, and the target business variable can be initialized. In any business code in the main function, the initialization data corresponding to the target business variable can be directly used.
[0155] In summary, in the embodiments of the present application, the electronic device can use the target business variable as a global variable or a static variable to initialize the business variable once. Since there is no need to initialize the target business variable multiple times, the running efficiency of the executable file can be improved.
[0156] In some implementations, the electronic device may generate code snippets for the data model and the business data through a code generator.
[0157] In some possible implementations, if at least one of the code generator, the data model, and the business data is updated, the code snippet is regenerated, specifically in the following situations:
[0158] In case one, if the code regenerator is updated, the electronic device regenerates the code snippets for the data model and the business data through the updated code regenerator.
[0159] In case 2, if the data model is updated, the electronic device regenerates the code snippet for the updated data model and business data through the code regenerator.
[0160] In case three, if the business data is updated, the electronic device regenerates the code snippet for the data model and the updated business data through the code regenerator.
[0161] Case 4: if the code regenerator and the data model are updated, the electronic device regenerates the code snippet for the updated data model and business data through the updated code regenerator.
[0162] Case five: if the code regenerator and the business data are updated, the electronic device regenerates the code snippet for the data model and the updated business data through the updated code regenerator.
[0163] Case six: if the data model and the business data are updated, the electronic device regenerates the code snippets for the updated data model and the updated business data through the code regenerator.
[0164] Case seven: if the code regenerator, the data model and the business data are updated, the electronic device regenerates the code snippet for the updated data model and the updated business data through the updated code regenerator.
[0165] In some possible implementations, if at least one of the business code and the code snippet is updated, the electronic device regenerates the executable file, specifically in the following situations:
[0166] In case one, if the business code is updated, the electronic device compiles and links the above code snippet and the updated business code to regenerate an executable file.
[0167] In case 2, if the above code snippet is updated, the electronic device compiles and links the updated code snippet and the business code to regenerate an executable file.
[0168] Case three: if the above code snippets and business codes are updated, the electronic device compiles and links the updated code snippets and the updated business codes to regenerate the executable file.
[0169] In summary, in an embodiment of the present application, if at least one of the code generator, the data model, and the business data is updated, the code snippet can be regenerated in an automated manner. If at least one of the business code and the code snippet is updated, the executable file can be regenerated in an automated manner. This automated method can improve the update efficiency of the code snippet and the update efficiency of the executable file. For example, if the business data is updated, when the manual method provided by the relevant technology is adopted, the programmer is required to update the data of the compile-time constants, and then execute the business code to generate an executable file. If the data processing method provided by the embodiment of the present application is adopted, it is only necessary for the electronic device to regenerate the code snippet based on the updated business data and the corresponding data model, and then compile and link the code snippet and the business code to obtain an executable file, thereby improving the update efficiency of the executable file relative to the relevant technology.
[0170] In some possible implementations, an electronic device may obtain a build file; the build file is used to describe a first generation rule for code snippets, a second generation rule for executable files, a first dependency relationship between data models and business data, and a second dependency relationship between business codes and code snippets; accordingly, the electronic device may generate code snippets from data models and business data based on the first generation rule and the first dependency relationship; and compile and link the business codes and code snippets based on the second generation rule and the second dependency relationship to obtain an executable file.
[0171] In some implementations, the electronic device may generate a code snippet for a data model and business data having a first dependency relationship according to a first generation rule.
[0172] In some implementations, the electronic device may compile and link the business code and code snippets having the second dependency relationship according to the second generation rule to obtain an executable file.
[0173] In some possible implementations, before the electronic device generates a code snippet from the data model and the business data based on the first generation rule and the first dependency relationship, it may also detect the legality and integrity of the business data based on the data model; accordingly, if the business data is detected to be legal and complete, the electronic device generates a code snippet from the data model and the business data based on the first generation rule and the first dependency relationship.
[0174] The electronic device may detect the legitimacy of the business data in the following manner, but is not limited thereto: the electronic device may detect whether the length and type of the business data conform to the length and type specified by the data model.
[0175] For example, if the type of name specified by the data model is character type, and the type of the business data name is numeric type, based on this, the electronic device can determine that the business data name is illegal.
[0176] For example, if the length of the ID specified by the data model is 1-8 bits, and the length of the service data ID is 10 bits, based on this, the electronic device can determine that the service data ID is illegal.
[0177] For example, if the data model specifies that the type of number is numeric and the length is 11 bits, and the type of the business data number is character and the length is 10 bits, based on this, the electronic device can determine that the business data number is illegal.
[0178] In some implementations, the electronic device detects the integrity of the business data including, but not limited to: the electronic device detects whether a required type business field is missing in the business data based on the data model. For example, assuming that the data model includes: a required type business field name, but the business data does not include the name item, then it is determined that the business data is incomplete.
[0179] In the embodiment of the present application, the electronic device can generate code snippets from the data model and the business data based on the first generation rule and the first dependency relationship in the build file; and compile and link the business code and the code snippet based on the second generation rule and the second dependency relationship in the build file to obtain an executable file. Since the above generation rules and dependency relationships are specified in the build file, the accuracy of the code snippet and the executable file can be guaranteed.
[0180] In addition, before the electronic device generates the code snippet from the data model and the business data based on the first generation rule and the first dependency, it can also detect the legality of the business data based on the data model; if the business data is detected to be legal, the electronic device generates the code snippet from the data model and the business data based on the first generation rule and the first dependency; on the contrary, if the business data is detected to be illegal, the electronic device does not generate the code snippet from the data model and the business data. Thus, the accuracy of the code snippet can be further guaranteed.
[0181] The preferred embodiments of the present application are described in detail above in conjunction with the accompanying drawings. However, the present application is not limited to the specific details in the above embodiments. Within the technical concept of the present application, the technical solution of the present application can be subjected to a variety of simple modifications, and these simple modifications all belong to the protection scope of the present application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present application will not further explain various possible combinations. For another example, the various different embodiments of the present application can also be arbitrarily combined, as long as they do not violate the ideas of the present application, they should also be regarded as the contents disclosed in the present application.
[0182] It should also be understood that in the various method embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0183] The method provided in the embodiment of the present application is described above, and the device provided in the embodiment of the present application is described below.
[0184] Figure 4 A schematic diagram of a data processing device 400 provided in an embodiment of the present application is shown as follows: Figure 4 As shown, the device 400 includes: a generation module 410 and a compile and link module 420, wherein the generation module 410 is used to generate code snippets corresponding to the business data based on the business data and the data model corresponding to the business data; the compile and link module 420 is used to compile and link the business code and the code snippet to obtain an executable file.
[0185] In some implementations, the device 400 also includes: a determination module 430 and an initialization module 440, wherein the determination module 430 is used to determine the target business variable in the executable file; the initialization module 440 is used to use the target business variable as a global variable or a static variable and initialize the target business variable.
[0186] In some implementations, the initialization module 440 is specifically used to: when the target business variable is used for the first time during the running of the executable file, use the target business variable as a static variable and initialize the target business variable.
[0187] In some implementations, the initialization module 440 is specifically used to: before executing the executable file, take the target business variable as a global variable and initialize the target business variable.
[0188] In some implementations, the generation module 410 is specifically used to: generate code snippets for the data model and business data through a code generator.
[0189] In some implementations, the generation module 410 is further used to: after the code generator generates the code snippet for the data model and the business data, if at least one of the code generator, the data model and the business data is updated, regenerate the code snippet.
[0190] In some implementations, the compile-link module 420 is further used to: after the business code and the code snippet are compiled and linked to obtain the executable file, if at least one of the business code and the code snippet is updated, regenerate the executable file.
[0191] In some possible implementations, the device 400 also includes: an acquisition module 450, used to acquire a build file; the build file is used to describe a first generation rule for code snippets, a second generation rule for executable files, a first dependency relationship between data models and business data, and a second dependency relationship between business codes and code snippets; accordingly, the generation module 410 is specifically used to generate code snippets from data models and business data based on the first generation rule and the first dependency relationship; the compilation and linking module 420 is specifically used to compile and link business codes and code snippets based on the second generation rule and the second dependency relationship to obtain an executable file.
[0192] In some possible implementations, the device 400 also includes: a detection module 460, which is used to detect the legality and integrity of the business data based on the data model before the generation module 410 generates code snippets from the data model and the business data based on the first generation rule and the first dependency relationship; accordingly, the generation module 410 is specifically used to: if the business data is detected to be legal and complete, then generate code snippets from the data model and the business data based on the first generation rule and the first dependency relationship.
[0193] In some implementations, the detection module 460 is specifically used to detect whether the length and type of the business data conform to the length and type specified by the data model.
[0194] It should be understood that the device embodiment and the method embodiment may correspond to each other, and similar descriptions may refer to the method embodiment. To avoid repetition, they will not be described here. Specifically, Figure 4 The apparatus 400 shown may perform Figure 2 The corresponding method embodiments, and the aforementioned and other operations and / or functions of each module in the device 400 are respectively to implement Figure 2 For the sake of brevity, the corresponding processes in each method are not repeated here.
[0195] The above describes the device 400 of the embodiment of the present application from the perspective of the functional module in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in hardware form, can be implemented by instructions in software form, and can also be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present application can be completed by the hardware integrated logic circuit and / or software form instructions in the processor, and the steps of the method disclosed in the embodiment of the present application can be directly embodied as a hardware decoding processor to perform, or a combination of hardware and software modules in the decoding processor to perform. Optionally, the software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in a memory, and the processor reads the information in the memory, and completes the steps in the above method embodiment in conjunction with its hardware.
[0196] Figure 5 It is a schematic block diagram of an electronic device provided in an embodiment of the present application.
[0197] like Figure 5 As shown, the electronic device may include:
[0198] The memory 510 and the processor 520, the memory 510 is used to store the computer program and transmit the program code to the processor 520. In other words, the processor 520 can call and run the computer program from the memory 510 to implement the method in the embodiment of the present application.
[0199] For example, the processor 520 may be configured to execute the above method embodiments according to instructions in the computer program.
[0200] In some embodiments of the present application, the processor 520 may include but is not limited to:
[0201] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0202] In some embodiments of the present application, the memory 510 includes but is not limited to:
[0203] Volatile memory and / or non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable ROM (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM) or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0204] In some embodiments of the present application, the computer program may be divided into one or more modules, which are stored in the memory 510 and executed by the processor 520 to complete the method provided by the present application. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0205] like Figure 5 As shown, the electronic device may also include:
[0206] The transceiver 530 may be connected to the processor 520 or the memory 510 .
[0207] The processor 520 may control the transceiver 530 to communicate with other devices, specifically, to send information or data to other devices, or to receive information or data sent by other devices. The transceiver 530 may include a transmitter and a receiver. The transceiver 530 may further include an antenna, and the number of antennas may be one or more.
[0208] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0209] The present application also provides a computer storage medium on which a computer program is stored, and when the computer program is executed by a computer, the computer can perform the method of the above method embodiment. In other words, the present application embodiment also provides a computer program product containing instructions, and when the instructions are executed by a computer, the computer can perform the method of the above method embodiment.
[0210] When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integration. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (digital video disc, DVD)), or a semiconductor medium (e.g., a solid state drive (solid state disk, SSD)), etc.
[0211] Those of ordinary skill in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0212] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the module is only a logical function division. There may be other division methods in actual implementation, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0213] The modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. For example, each functional module in each embodiment of the present application may be integrated into a processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0214] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A data processing method, characterized in that: include: Based on the business data and a data model corresponding to the business data, generate a code snippet corresponding to the business data; The business code and the code snippet are compiled and linked to obtain an executable file.
2. The method according to claim 1, characterized in that Also includes: Determining a target business variable in the executable file; The target business variable is used as a global variable or a static variable, and the target business variable is initialized.
3. The method according to claim 2, characterized in that The step of taking the target business variable as a global variable or a static variable and initializing the target business variable includes: When the target business variable is used for the first time during the running of the executable file, the target business variable is used as a static variable and the target business variable is initialized.
4. The method according to claim 2, characterized in that: The step of taking the target business variable as a global variable or a static variable and initializing the target business variable includes: Before executing the executable file, the target business variable is used as a global variable and the target business variable is initialized.
5. The method according to any one of claims 1 to 4, characterized in that: The step of generating a code snippet corresponding to the business data based on the business data and a data model corresponding to the business data includes: The code snippet is generated by a code generator based on the data model and the business data.
6. The method according to claim 5, characterized in that After the code snippet is generated by the code generator for the data model and the business data, the method further includes: If at least one of the code generator, the data model and the business data is updated, the code snippet is regenerated.
7. The method according to any one of claims 1 to 4, characterized in that: After the business code and the code snippet are compiled and linked to obtain an executable file, the process further includes: If at least one of the business code and the code snippet is updated, the executable file is regenerated.
8. The method according to any one of claims 1 to 4, characterized in that: Also includes: Obtaining a build file; the build file is used to describe a first generation rule of the code snippet, a second generation rule of the executable file, a first dependency relationship between the data model and the business data, and a second dependency relationship between the business code and the code snippet; The step of generating a code snippet corresponding to the business data based on the business data and a data model corresponding to the business data includes: Based on the first generation rule and the first dependency relationship, generate the code snippet from the data model and the business data; The business code and the code snippet are compiled and linked to obtain an executable file, including: The business code and the code snippet are compiled and linked based on the second generation rule and the second dependency relationship to obtain the executable file.
9. The method according to claim 8, characterized in that Before generating the code snippet from the data model and the business data based on the first generation rule and the first dependency relationship, the method further includes: Detecting the legitimacy and integrity of the business data based on the data model; The step of generating the code snippet from the data model and the business data based on the first generation rule and the first dependency relationship includes: If the business data is detected to be legal and complete, the code snippet is generated from the data model and the business data based on the first generation rule and the first dependency relationship.
10. The method according to claim 9, characterized in that Detecting the legitimacy of the business data based on the data model includes: Check whether the length and type of the business data conform to the length and type specified by the data model.
11. A data processing device, characterized in that: include: A generation module, used to generate a code snippet corresponding to the business data based on the business data and a data model corresponding to the business data; The compile and link module is used to compile and link the business code and the code fragment to obtain an executable file.
12. An electronic device, characterized in that: include: A processor and a memory, the memory being used to store a computer program, and the processor being used to call and run the computer program stored in the memory to execute the method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that: Used to store a computer program, wherein the computer program causes a computer to execute the method according to any one of claims 1 to 10.
14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 10 is implemented.
