CN113934407A - Method, device, medium and computing equipment for calling interfaces among different language codes - Google Patents

Method, device, medium and computing equipment for calling interfaces among different language codes Download PDF

Info

Publication number
CN113934407A
CN113934407A CN202111493523.0A CN202111493523A CN113934407A CN 113934407 A CN113934407 A CN 113934407A CN 202111493523 A CN202111493523 A CN 202111493523A CN 113934407 A CN113934407 A CN 113934407A
Authority
CN
China
Prior art keywords
language
interface
language code
object format
code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202111493523.0A
Other languages
Chinese (zh)
Other versions
CN113934407B (en
Inventor
黄兴勃
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba Cloud Computing Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Alibaba Cloud Computing Ltd filed Critical Alibaba Cloud Computing Ltd
Priority to CN202111493523.0A priority Critical patent/CN113934407B/en
Publication of CN113934407A publication Critical patent/CN113934407A/en
Application granted granted Critical
Publication of CN113934407B publication Critical patent/CN113934407B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/20Software design
    • G06F8/24Object-oriented
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Abstract

The embodiments disclosed in the specification provide a method, a device, a medium and a computing device for calling an interface between codes in different languages. In the data processing process, if a calculation of a certain extended function needs to be implemented in the process of executing data processing based on the first language code and the calculation needs to be executed based on the second language code, the calling of the second language code can be implemented by using a standard interactive interface between different language codes.

Description

Method, device, medium and computing equipment for calling interfaces among different language codes
Technical Field
Embodiments of the present disclosure relate to the field of database technologies, and in particular, to a method, an apparatus, a medium, and a computing device for invoking interfaces between different language codes.
Background
Data processing processes created by current data stream processing systems typically run in a specific language runtime environment, that is, the data processing processes are typically only capable of directly executing code written based on that specific language. In some cases, code for implementing extended functionality may be written in other languages and configured to the data processing process in anticipation of the data processing process being able to implement the extended functionality.
Therefore, how to enable the data processing process to realize the extended function becomes a technical problem to be solved urgently.
Disclosure of Invention
Embodiments of the present specification provide a method, an apparatus, a medium, and a computing device for executing a data processing task, so as to enable a data processing process to call code written in a second language to implement extended functionality during execution of the data processing task based on code written in a first language.
The technical scheme provided by the embodiments of the specification is as follows:
according to a first aspect of the embodiments of the present specification, there is provided a method for calling an interface between different language codes, which is applied to a data processing process running on a first virtual machine, and is executed if it is determined that target computation needs to be executed based on a preset second language code during data processing based on the first language code, the method including:
converting the corresponding calculation parameters in the first language object format into calculation parameters in a C object format based on the first language code, taking the calculation parameters in the C object format as interface input, and calling a first interface; the first interface is a standard interactive interface between the first language and the C language;
converting the calculation parameters in the C object format into calculation parameters in a second language object format based on a preset C language code, and calling a second interface by taking the calculation parameters in the second language object format as interface input; the second interface is a standard interactive interface between the second language and the C language;
based on the second language code, executing target calculation according to the calculation parameters of the second language object format to obtain a calculation result, converting the calculation result of the second language object format into a calculation result of a C object format, and calling a second interface by taking the calculation result of the C object format as interface input;
and converting the calculation result in the C object format into a calculation result in a first language object format based on the C language code, and calling the first interface by taking the calculation result in the first language object format as an interface input.
According to a second aspect of the various embodiments of the present description, a computer-readable storage medium is proposed, on which a computer program is stored which, when being executed by a processor, carries out the method of the first aspect.
According to a third aspect of various embodiments herein, there is provided a computing device comprising a memory, a processor; the memory is for storing computer instructions executable on the processor for implementing the method of the first aspect when executing the computer instructions.
In the above technical solution, in the data processing process executing data processing based on the first language code, if a calculation of a certain extended function needs to be implemented and the calculation needs to be executed based on the second language code, the following call flow may be executed:
1. and based on the first language code, converting the object format of the calculation parameters required by calculation into an object format supported by the C language (namely C object format), and calling a standard interaction interface between the first language and the C language by the calculation parameters carrying the C object format.
2. And based on the C language code, further converting the calculation parameters in the C object format into calculation parameters in a second language object format, and calling a standard interaction interface between the C language and the second language by carrying the calculation parameters in the second language object format.
3. And executing target calculation according to the calculation parameters in the second language object format based on the second language code to obtain a calculation result, converting the calculation result into a C object format, and calling a standard interaction interface between the C language and the second language by carrying the calculation result in the C object format.
4. And based on the C language code, converting the calculation result in the C object format into a calculation result in a first language object format, and calling a standard interaction interface between the C language and the second language by carrying the calculation result in the first language object format.
By the technical scheme, the data processing process can realize the extended function depending on the second language code in the data processing process based on the first language code.
Drawings
Fig. 1 is a schematic flowchart of an interface calling method between different language codes provided in this specification.
Fig. 2 exemplarily provides an interface connection relationship among the first language code, the C language code, and the second language code.
FIG. 3 is an exemplary flow for a second type of thread to initialize a runtime environment for second language code.
FIG. 4 illustrates a process for a first type of thread to initialize a sub-runtime environment for second language code.
FIG. 5 is a flow chart illustrating a first type of thread execution interface calling method.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
It should be noted that: in other embodiments, the steps of the corresponding methods are not necessarily performed in the order shown and described herein. In some other embodiments, the method may include more or fewer steps than those described herein. Moreover, a single step described in this specification may be broken down into multiple steps for description in other embodiments; multiple steps described in this specification may be combined into a single step in other embodiments.
The data flow processing system is a software system developed based on a first language, and comprises a plurality of computing nodes distributed in a streaming manner, a user submits own data to the data flow processing system, the data can flow among the computing nodes, and the computing nodes complete data processing tasks through cooperation. A common data stream processing system may be, for example, Flink.
When data processing is required, a data processing process is usually created on each computing node, and data processing is actually performed by the data processing process on each computing node. Data processing processes created by current data stream processing systems typically run on a first virtual machine, which generally only supports the direct running of code written based on a first language. In some cases, however, there is a need for code that may be written based on a second language for implementing extended functionality and configured to a data processing process in anticipation of the data processing process being able to implement the extended functionality.
One reason for the above-mentioned need is given here by way of example. The data stream system can support user-defined extension functions, a user can request to deploy the user-defined extension functions on one or more computing nodes, and the data processing processes on the corresponding computing nodes can realize the corresponding extension functions aiming at data in the data processing process. For example, a user may customize a function and configure the function to a compute node. In practice, the user may not have the ability to write code for implementing extended functionality in a first language, but may only have the ability to write code for implementing extended functionality in a second such simple language, which creates the above-mentioned need.
Therefore, how to enable the data processing process to realize the extended function becomes a technical problem to be solved urgently.
An optional technical solution to solve the above technical problem is that, when a data processing process on a compute node needs to implement an extended function that depends on a second language code, another auxiliary processing process may be pulled up, and the auxiliary processing process may run in a second running environment instead of a first virtual machine, so that data interaction may be performed between the data processing process and the auxiliary processing process by using a technical mechanism of inter-process communication, that is, the data processing process sends computation parameters of computation that needs to be implemented to the auxiliary processing process, and after the auxiliary processing process performs the computation, the computation result is returned to the data processing process.
In addition, in order to avoid the large performance overhead brought to the computing node by the inter-process communication, the present specification provides another technical solution to solve the above technical problem. In the data processing process, if a calculation for implementing an extended function is required to be performed based on the second language code in the process of performing data processing based on the first language code, the following call flow may be performed:
1. and based on the first language code, converting the object format of the calculation parameters required by calculation into an object format supported by the C language (namely C object format), and calling a standard interaction interface between the first language and the C language by the calculation parameters carrying the C object format.
2. And based on the C language code, further converting the calculation parameters in the C object format into calculation parameters in a second language object format, and calling a standard interaction interface between the C language and the second language by carrying the calculation parameters in the second language object format.
3. And executing target calculation according to the calculation parameters in the second language object format based on the second language code to obtain a calculation result, converting the calculation result into a C object format, and calling a standard interaction interface between the C language and the second language by carrying the calculation result in the C object format.
4. And based on the C language code, converting the calculation result in the C object format into a calculation result in a first language object format, and calling a standard interaction interface between the C language and the second language by carrying the calculation result in the first language object format.
The first and second languages described above may generally refer to any high-level programming language other than the C language, and the first and second languages are different programming languages. The high level languages other than the C language may be, for example, JAVA, Python, Go, PHP, Ruby, and the like.
The technical principle of the present solution is that almost all high-level programming languages other than the C language support syntactically interaction with the C language. In the process of running the first language code in the first virtual machine, if an operation of calling an interface between the first language code and the C language code is involved, the operation still belongs to the process of executing the first language code, and is equivalent to nesting a layer of C language code inwards in the first language code. In the process of running the C language code through the interface between the C language code and the second language code, if the operation related to further calling the interface between the C language code and the second language code still belongs to the process of executing the C language code, the operation is equivalent to nesting one layer of the second language code in the C language code. And because the operation of running the C language code through the interface call belongs to the process of executing the first language code, the operation of essentially running the second language code belongs to the process of executing the first language code, which is equivalent to nesting a layer of C language code inwards in the first language code first and then further nesting a layer of the second language code inwards in the C language code. Therefore, the first language code, the C language code and the second language code can all run in the same data processing process created on the first virtual machine.
Based on similar principles, in the process of running the second language code, the calculation depending on the first language code can be realized in the process of running the second language code by calling the interface between the second language code and the C language code and then running a code module of the C language code, which is about calling the interface between the C language code and the first language code.
By the technical scheme, the data processing process can realize the extended function depending on the second language code in the data processing process based on the first language code, and meanwhile, the first language code, the second language code and the C language code can be realized in the same process (data processing process), so that interprocess communication can not be involved, and great performance overhead can not be brought to a computing node.
The technical solution provided in the present specification is described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic flowchart of an interface calling method between different language codes provided in this specification, including the following steps:
s100: and converting the corresponding calculation parameters in the first language object format into calculation parameters in the C object format based on the first language code, and calling the first interface by taking the calculation parameters in the C object format as interface input.
S102: and converting the calculation parameters in the C object format into calculation parameters in a second language object format based on a preset C language code, and calling a second interface by taking the calculation parameters in the second language object format as interface input.
S104: and executing target calculation according to the calculation parameters in the second language object format based on the second language code to obtain a calculation result, converting the calculation result in the second language object format into a calculation result in a C object format, and calling a second interface by taking the calculation result in the C object format as interface input.
S106: and converting the calculation result in the C object format into a calculation result in a first language object format based on the C language code, and calling the first interface by taking the calculation result in the first language object format as an interface input.
The method flow shown in fig. 1 may be applied to a data processing process that is typically run in a first virtual machine of a compute node. The data processing process may execute the method flow shown in fig. 1 if it is determined that the target calculation needs to be executed based on the preset second language code in the process of executing data processing based on the first language code.
The second language code is code for implementing extended functionality, which may be user written and configured to the compute node. In some embodiments, the second language code may include several functions that may be used to implement the computing power corresponding to the extended functionality.
For convenience of description, the calculation corresponding to the extended function implemented by the second language code is referred to as target calculation, the input required by the target calculation is referred to as calculation parameter, and the output of the target calculation is referred to as calculation result.
It should be noted that the first language code deployed on the computing node generally includes several code modules, some of which are conventional code modules for implementing functions independent of the second language code, which occur in the data processing process, and other code modules related to the interface calling scheme for implementing step S100, and other steps implemented based on the first language code in the more specific embodiments later. The description in the first language code is not made herein, but focuses on code modules in the first language code that relate to the interface calling scheme.
It should be noted that the second language code also typically includes several code modules, some of which are used to implement extended functions (e.g., custom functions of users), others of which are used to provide some attribute information (e.g., variables, constants), and others of which are used to implement functions related to the interface calling scheme, such as calling a standard interactive interface with the C language code.
Furthermore, the role of C language code can be understood as a bridge between the first language code and the second language code. Fig. 2 exemplarily provides an interfacing relationship among a first language code, a C language code, and a second language code, and in the example provided in fig. 2, the first language is JAVA, and the second language is Python.
It is emphasized that by "execute YY based on XX code" herein is meant that the capability required by a data processing process to execute YY is provided by XX code.
For convenience of description, the standard interactive interface defined in the first syntax for interacting with the C language is referred to as a first interface, and the standard interactive interface defined in the second syntax for interacting with the C language is referred to as a second interface.
It should also be noted that different language code typically requires different object formats. The calculation parameters of the target calculation obtained in the data processing process of the data processing process based on the first language code are usually in a first language object format, and the input required when the second language code is calculated is required to be in a second language object format. Considering that the interfaces between the C language code and the first language code and between the C language code and the second language code are bridges, the calculation parameter needs to be transmitted through the C language code, so that the data processing process actually interacts with the C language code when calling the first interface based on the first language code, and therefore the calculation parameter in the first language object format needs to be temporarily converted into the calculation parameter in the C language object format before calling the second interface based on the C language code. And because the second interface is called based on the C language code to actually interact with the second language code, the calculation parameters in the C object format need to be converted into the calculation parameters in the second language object format, and then the second interface can be called to calculate the calculation parameters in the second language object format based on the second language code.
After the target calculation is executed based on the second language code, the calculation result needs to be fed back to the processing link executed by the data processing process based on the first language code through two consecutive format conversions. The principle here is similar to format conversion of calculation parameters and is not described in detail.
In some embodiments, before calling the first interface for the interface input based on the first language code with the calculation parameters in the C-object format, the first interface may also be called for the interface input based on the first language code with a function identification of a target function in the second language code for performing the target calculation. In this way, before calling the second interface based on the C language code with the calculation parameter in the second language object format as the interface input, the second interface may also be called based on the C language code with the function identifier of the target function as the interface input. In this case, the objective function may be executed according to the calculation parameters in the second language object format based on the second language code.
In some embodiments, other calculations may be involved in performing the target calculation based on the second language code, and may require obtaining other calculation parameters from other calculation links of the data processing flow advanced based on the first language code. Therefore, if it is determined that other calculations need to be performed based on the first language code during the process of performing the target calculation according to the calculation parameters in the second language object format based on the second language code, the corresponding other calculation parameters in the second language object format are converted into other calculation parameters in the C object format, and the second interface is called by taking the other calculation parameters in the C object format as interface input. Then, based on the C language code, the other calculation parameters in the C object format may be converted into other calculation parameters in the first language object format, and the first interface may be called with the other calculation parameters in the first language object format as interface inputs. Then, based on the first language code, other calculation is executed according to other calculation parameters in the first language object format to obtain other calculation results, the other calculation results in the first language object format are converted into other settlement results in the C object format, and the other calculation results in the C object format are used as interface input to call the first interface. Then, the other calculation results in the C object format may be converted into other calculation results in the second language object format based on the C language code, and the second interface may be called with the other calculation results in the second language object format as interface inputs.
Accordingly, the first interface may be called based on the second language code with the function identification of the other function in the first language code for implementing the other computation as an interface input before the second interface is called based on the second language code with the other computation parameters in the C-object format as interface inputs. In this way, the first interface may be called with the function identification of the other function as the interface input based on the C language code before the first interface is called with the other calculation parameter in the first language object format as the interface input based on the C language code. As such, other functions may be performed based on the first language code according to other calculation parameters in the first language object format.
In some embodiments, if the data processing process determines that a computing element needs to rely on the second language code to implement, the current progress state for the data processing flow may be interrupted and the method of FIG. 1 may be executed instead.
In other embodiments, the data processing process may further create threads, leaving different threads specifically responsible for different tasks. In particular, the data processing process may create a main thread that is responsible for advancing the data processing flow based on the first language code, and further, the data processing process may create several first type threads. Wherein each first type thread can execute the method flow shown in fig. 1 for a computation depending on the second language implementation.
Further, considering that each first type thread needs the execution environment of the second language code when executing the method flow shown in fig. 1, a general idea is that one first type thread initializes the execution environment of the second language code, and other first type threads can reuse the execution environment. However, if the execution environment of the second language code is initialized by a certain first type thread, a contention problem between a plurality of first type threads (for example, a lock of the second language interpreter) may be caused, and after the execution of the first type thread which initializes the execution environment of the second language code is ended, the corresponding execution environment is also closed, which easily causes the execution failure of other first type threads which are using the execution environment.
Thus, the data processing process may also create a second type of thread for assisting the first type of thread. The second type of threads may be daemon threads, and may be understood as daemon threads that are currently executed, and the second type of threads are not recycled only if there is at least one first type of thread that is currently executed. It should be noted that the second type of thread may be created even though the data processing process may only allow one first type of thread to execute.
Before the first type of thread performs the method, the second type of thread may perform the following initialization steps:
based on the first language code, taking a request for initializing the operating environment of the second language code as interface input, and calling the first interface; based on the C language code, taking a request for initializing the operating environment of the second language code as interface input, and calling a second interface; based on the second language code, in response to a request to initialize an execution environment of the second language code, the execution environment of the second language code is initialized. The step of the second type thread initializing the execution environment of the second language code also involves interface calls between different languages.
Further, the initialization step performed by the second type of thread may further include: based on the C language code, taking a request for starting the multithreading function as interface input, and calling a second interface; the multithreading function is a function supporting a plurality of first-class threads to respectively realize different calculations executed based on second language codes; the multi-threaded function is initialized in response to a request to initiate the multi-threaded function based on the second language code. In addition, based on the C language code, a request for loading one or more code modules in a second language code shared by a plurality of first type threads is used as interface input to call a second interface; based on the second language code, in response to a request to load one or more code modules in the second language code, loading the corresponding code modules in the execution environment of the second language code.
Further, the initialization step performed by the second type of thread may further include: based on the C language code, taking a request for creating a second language interpreter as an interface input, and calling a second interface; based on the second language code, a second language interpreter is created in a runtime environment of the second language code in response to a request to create the second language interpreter.
Furthermore, in some embodiments, the plurality of first type threads may all multiplex the second language interpreter created by the second type threads, however, in order to avoid the contention of resources in the running environment of the plurality of first type threads, the first type threads may further perform the following initialization steps before executing the method flow shown in fig. 1:
based on a first language code, taking a request for initializing a sub-operation environment corresponding to the first type of thread as interface input, and calling a second interface; based on the C language code, taking a request for initializing the sub-operation environment corresponding to the first type of thread as interface input, and calling a second interface; and responding to a request for initializing the sub-operating environment corresponding to the first type of thread based on the second language code, and initializing the sub-operating environment corresponding to the first type of thread in the operating environment of the second language code.
Further, the initialization step performed by the first type thread may further include: based on the C language code, taking a request for creating a second language sub-interpreter as an interface input, and calling a second interface; and responding to a request for creating a second language sub-interpreter based on the second language code, and creating the sub-interpreter in the sub-running environment corresponding to the first type of thread according to the second language interpreter. In this way, each first type thread may have a dedicated child interpreter, avoiding contention for the thread lock of the interpreter created by the second thread. Meanwhile, different first-class threads also have independent variable namespaces.
Further, the initialization step performed by the first type thread may further include: based on the C language code, taking a request for loading a main code module in the second language code as interface input, and calling a second interface; and responding to a request for loading the main code module in the second language code based on the second language code, and loading the main code module in the second language code in the sub-running environment corresponding to the first type of thread.
Further, the initialization step performed by the first type thread may further include: based on the C language code, taking a request for acquiring the attribute table of the main code module as interface input, and calling a second interface; based on the second language code, responding to the request for obtaining the attribute table of the main code module, and obtaining the attribute table of the main code module; based on the C language code, the attribute of the main code module is added to the calculation parameter of the target calculation.
Furthermore, the second language interpreter or sub-interpreter usually has a thread lock, and thus, both in the initialization step performed by the first type of thread and in the method flow shown in fig. 1, operations for acquiring and releasing the thread lock are involved, and for these operations, interface calls between different codes are involved as well.
FIG. 3 is an exemplary flow for a second type of thread to initialize a runtime environment for second language code. In the example provided in fig. 3, the first language is JAVA and the second language is Python. As shown in fig. 3, for ease of understanding, the different languages are considered as different execution entities, however it should be understood that in reality the second type of threads perform different operations based on different language code.
FIG. 4 illustrates a process for a first type of thread to initialize a sub-runtime environment for second language code. In the example provided in fig. 4, the first language is JAVA and the second language is Python. As shown in fig. 4, for ease of understanding, different languages are considered as different execution entities, however, it should be understood that in reality, threads of the first type perform different operations based on different language code.
FIG. 5 is a flow chart illustrating a first type of thread execution interface calling method. In the example provided in fig. 5, the first language is JAVA and the second language is Python. As shown in fig. 5, for ease of understanding, different languages are considered as different execution entities, however, it should be understood that in reality, threads of the first type perform different operations based on different language code.
In addition, when the interface is called, if the interface does not need to carry the parameters or only needs to carry a single parameter, the overhead of constructing the argument Tuple can be avoided, the interface of the non-parameter or single-parameter function supported by the second syntax is used for parameter transmission, and the performance of the non-parameter or single-parameter function is improved. For example, based on the C language code, when the calculation parameter carrying the second language object format calls the second interface, a single parameter function interface may be used to avoid the overhead of constructing the argument Tuple.
The data processing process may need to implement the calculation depending on the same second function in a plurality of successive calculation links in the process of advancing data processing, and for this purpose, the function identifier of the second function obtained last time may be recorded based on the C language code, so that when the second function is needed next time, the second function is quickly located by using the recorded function identifier.
In some embodiments, when configuring the self-written second language code to the computing node, a user may select and set to subsequently map the computing parameter from the basic data type data to the numpy array, and at the same time, the self-written second language code includes a function supporting the numpy array format, so that the function supporting the numpy array format may be subsequently used to process the computing parameter in the numpy array format, and the computing performance may be improved by using the vector computing supported by the numpy array.
In addition, the software package provided in this specification for implementing the flow shown in fig. 1 and the corresponding steps in the various embodiments (e.g., the initialization step of the first type of thread, the initialization step of the second type of thread) can get rid of the running dependency and the compiling dependency on the compute node. The second library can be stored in the computing node in advance, when the software package is deployed on the computing node, the path of the second library can be dynamically read, and the second library is loaded, so that the problem that the software package can only be installed by source codes is solved. Meanwhile, the second library can be dynamically loaded, so that the pluggable characteristic of the software package to the node equipment is realized, and the second library can be loaded without restarting the first virtual machine on the computing node.
The data types supported by the data stream processing system provided by the present specification may include not only conventional data types (such as character type, wide character type, integer type, floating point type, double floating point type, boolean type), but also more complex data types such as time type, Decimal type, and the like.
The present specification also provides an interface calling apparatus between different language codes, which is applied to a data processing process running on a first virtual machine, and is used when it is determined that target computation needs to be executed based on a preset second language code in a data processing process executed based on the first language code, the apparatus including:
the first execution module converts the corresponding calculation parameters in the first language object format into the calculation parameters in the C object format based on the first language code, takes the calculation parameters in the C object format as interface input and calls a first interface; the first interface is a standard interactive interface between the first language and the C language;
the second execution module converts the calculation parameters in the C object format into the calculation parameters in the second language object format based on a preset C language code, and calls a second interface by taking the calculation parameters in the second language object format as interface input; the second interface is a standard interactive interface between the second language and the C language;
the third execution module executes target calculation according to the calculation parameters in the second language object format based on the second language code to obtain a calculation result, converts the calculation result in the second language object format into a calculation result in the C object format, and calls the second interface by taking the calculation result in the C object format as interface input;
and the fourth execution module converts the calculation result in the C object format into the calculation result in the first language object format based on the C language code, takes the calculation result in the first language object format as the interface input and calls the first interface.
The present specification also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the functionality of an untrusted execution module or a trusted execution module.
The present specification also provides a computing device comprising a memory, a processor; the memory is for storing computer instructions executable on the processor for implementing the functions of the untrusted execution module or the trusted execution module when the computer instructions are executed.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
For convenience of description, the above devices are described as being divided into various units by function, and are described separately. Of course, the functions of the various elements may be implemented in the same one or more software and/or hardware implementations of the present description.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
This description may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The specification may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. In a typical configuration, a computer includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic disk storage, quantum memory, graphene-based storage media or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In summary, in some embodiments disclosed herein, the digital article and the digital identity are connected by digital identity technology, and the digital identity may further include identity authentication information so that the transaction of the digital article can meet the requirements of KYC regulation. In some embodiments, some or all of the digital identities are fully authenticated by real name, providing a fully authenticated blockchain-based transaction system. The system is beneficial to the operation of anti-money laundering and fraud, and becomes a true credible transaction system. In some embodiments, the recording and verification functions of the digital article and the digital identity are combined, so that transaction elements such as transaction objects, transaction participants and the like can be recorded and verified conveniently, and the convenience and reliability of transactions are improved. In other embodiments, the intelligent contract in the blockchain system may be invoked by the client of the transacting party independently of the digital identity to create tables of associations between the digital item and its owner on the chain and store the tables of associations in the intelligent contract, thereby creditably recording ownership of the digital item on the chain.
The foregoing describes several embodiments of the present specification. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The terminology used in the description of the various embodiments is for the purpose of describing particular embodiments only and is not intended to be limiting of the embodiments herein. As used in this specification and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in various embodiments of the present description to describe various information, the information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, the first information may also be referred to as second information, and similarly, the second information may also be referred to as first information, without departing from the scope of the various embodiments herein. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, as for the method embodiment, since it is substantially similar to the method embodiment, it is relatively simple to describe, and reference may be made to the partial description of the method embodiment for relevant points. The above-described method embodiments are merely illustrative, wherein the modules described as separate components may or may not be physically separate, and the functions of the modules may be implemented in one or more software and/or hardware when implementing the embodiments of the present specification. And part or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
The above description is only a preferred embodiment of the present disclosure, and should not be taken as limiting the present disclosure, and any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present disclosure should be included in the scope of protection of the present disclosure.

Claims (15)

1. An interface calling method between different language codes is applied to a data processing process running in a first language running environment, and in the process of executing data processing based on the first language codes, if it is determined that target calculation needs to be executed based on preset second language codes, the method is executed, and the method comprises the following steps:
converting the corresponding calculation parameters in the first language object format into calculation parameters in a C object format based on the first language code, taking the calculation parameters in the C object format as interface input, and calling a first interface; the first interface is a standard interactive interface between the first language and the C language;
converting the calculation parameters in the C object format into calculation parameters in a second language object format based on a preset C language code, and calling a second interface by taking the calculation parameters in the second language object format as interface input; the second interface is a standard interactive interface between the second language and the C language;
based on the second language code, executing target calculation according to the calculation parameters of the second language object format to obtain a calculation result, converting the calculation result of the second language object format into a calculation result of a C object format, and calling a second interface by taking the calculation result of the C object format as interface input;
and converting the calculation result in the C object format into a calculation result in a first language object format based on the C language code, and calling the first interface by taking the calculation result in the first language object format as an interface input.
2. The method of claim 1, further comprising, prior to invoking the first interface for interface input based on the first language code with the computational parameters in the C-object format:
calling a first interface by taking a function identifier of a target function for executing target calculation in the second language code as an interface input based on the first language code;
before calling the second interface by taking the calculation parameters in the second language object format as interface input based on the C language code, the method further comprises the following steps:
based on the C language code, taking the function identifier of the target function as an interface input to call a second interface;
based on the second language code, performing a target computation according to the computation parameters in the second language object format, including:
based on the second language code, the objective function is executed according to the calculation parameters in the second language object format.
3. The method of claim 1, performing a target computation based on the second language code according to the computation parameters in the second language object format, comprising:
based on the second language code, in the process of executing target calculation according to the calculation parameters in the second language object format, if it is determined that other calculation needs to be executed based on the first language code, converting the corresponding other calculation parameters in the second language object format into other calculation parameters in the C object format, and calling a second interface by taking the other calculation parameters in the C object format as interface input;
converting other calculation parameters in the C object format into other calculation parameters in the first language object format based on the C language code, and calling the first interface by taking the other calculation parameters in the first language object format as interface input;
based on the first language code, executing other calculation according to other calculation parameters in the first language object format to obtain other calculation results, converting the other calculation results in the first language object format into other settlement results in the C object format, and calling the first interface by taking the other calculation results in the C object format as interface input;
and converting other calculation results in the C object format into other calculation results in the second language object format based on the C language code, and calling the second interface by taking the other calculation results in the second language object format as interface input.
4. The method of claim 3, further comprising, prior to invoking the second interface for interface input based on the second language code with other computational parameters in the C-object format:
calling the first interface by taking function marks of other functions used for realizing other calculations in the first language code as interface input based on the second language code;
before calling the first interface by taking other calculation parameters in the first language object format as interface input based on the C language code, the method further comprises the following steps:
based on the C language code, taking the function identification of the other functions as an interface input to call a first interface;
performing other calculations based on the first language code according to other calculation parameters in the first language object format, including:
based on the first language code, other functions are performed according to other calculation parameters in the first language object format.
5. The method of claim 1, wherein the data processing process executes the method by creating a first type of thread, the data processing process further creating a second type of thread for assisting the first type of thread;
before the first type of thread executes the method, the second type of thread executes the following initialization steps:
based on the first language code, taking a request for initializing the operating environment of the second language code as interface input, and calling the first interface;
based on the C language code, taking a request for initializing the operating environment of the second language code as interface input, and calling a second interface;
based on the second language code, in response to a request to initialize an execution environment of the second language code, the execution environment of the second language code is initialized.
6. The method of claim 5, wherein the initializing step performed by the second type of thread further comprises:
based on the C language code, taking a request for starting the multithreading function as interface input, and calling a second interface; the multithreading function is a function supporting a plurality of first-class threads to respectively realize different calculations executed based on second language codes;
the multi-threaded function is initialized in response to a request to initiate the multi-threaded function based on the second language code.
7. The method of claim 5, wherein the initializing step performed by the second type of thread further comprises:
based on the C language code, taking a request for creating a second language interpreter as an interface input, and calling a second interface;
based on the second language code, a second language interpreter is created in a runtime environment of the second language code in response to a request to create the second language interpreter.
8. The method of claim 6, wherein the initializing step performed by the second type of thread further comprises:
based on the C language code, taking a request for loading one or more code modules in a second language code shared by a plurality of first type threads as interface input, and calling a second interface;
based on the second language code, in response to a request to load one or more code modules in the second language code, loading the corresponding code modules in the execution environment of the second language code.
9. The method of claim 5, wherein prior to executing the method, the first type of thread further performs the following initialization steps:
based on a first language code, taking a request for initializing a sub-operation environment corresponding to the first type of thread as interface input, and calling a second interface;
based on the C language code, taking a request for initializing the sub-operation environment corresponding to the first type of thread as interface input, and calling a second interface;
and responding to a request for initializing the sub-operating environment corresponding to the first type of thread based on the second language code, and initializing the sub-operating environment corresponding to the first type of thread in the operating environment of the second language code.
10. The method of claim 9, wherein the initializing step performed by the first type of thread further comprises:
based on the C language code, taking a request for creating a second language sub-interpreter as an interface input, and calling a second interface;
and responding to a request for creating a second language sub-interpreter based on the second language code, and creating the sub-interpreter in the sub-running environment corresponding to the first type of thread according to the second language interpreter.
11. The method of claim 9, wherein the initializing step performed by the first type of thread further comprises:
based on the C language code, taking a request for loading a main code module in the second language code as interface input, and calling a second interface;
and responding to a request for loading the main code module in the second language code based on the second language code, and loading the main code module in the second language code in the sub-running environment corresponding to the first type of thread.
12. The method of claim 11, wherein the initializing step performed by the first type of thread further comprises:
based on the C language code, taking a request for acquiring the attribute table of the main code module as interface input, and calling a second interface;
based on the second language code, responding to the request for obtaining the attribute table of the main code module, and obtaining the attribute table of the main code module;
based on the C language code, the attribute of the main code module is added to the calculation parameter of the target calculation.
13. The method of claim 1, wherein the first language comprises JAVA and the second language comprises Python.
14. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method of any one of claims 1 to 13.
15. A computing device comprising a memory, a processor; the memory is for storing computer instructions executable on the processor for implementing the method of any one of claims 1 to 13 when the computer instructions are executed.
CN202111493523.0A 2021-12-08 2021-12-08 Method, device, medium and computing equipment for calling interfaces among different language codes Active CN113934407B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111493523.0A CN113934407B (en) 2021-12-08 2021-12-08 Method, device, medium and computing equipment for calling interfaces among different language codes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111493523.0A CN113934407B (en) 2021-12-08 2021-12-08 Method, device, medium and computing equipment for calling interfaces among different language codes

Publications (2)

Publication Number Publication Date
CN113934407A true CN113934407A (en) 2022-01-14
CN113934407B CN113934407B (en) 2022-06-07

Family

ID=79288900

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111493523.0A Active CN113934407B (en) 2021-12-08 2021-12-08 Method, device, medium and computing equipment for calling interfaces among different language codes

Country Status (1)

Country Link
CN (1) CN113934407B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048845A (en) * 2023-02-07 2023-05-02 之江实验室 Data processing method and device, storage medium and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779071A (en) * 2012-06-14 2012-11-14 华为技术有限公司 Method, device and system for calling software interface
CN110888674A (en) * 2019-11-28 2020-03-17 支付宝(杭州)信息技术有限公司 Method and device for executing security calculation in Python virtual machine
CN111381817A (en) * 2020-03-25 2020-07-07 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for realizing cross-platform multi-language development
CN113626038A (en) * 2021-07-06 2021-11-09 曙光信息产业(北京)有限公司 Code conversion method, device, equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779071A (en) * 2012-06-14 2012-11-14 华为技术有限公司 Method, device and system for calling software interface
CN110888674A (en) * 2019-11-28 2020-03-17 支付宝(杭州)信息技术有限公司 Method and device for executing security calculation in Python virtual machine
CN111381817A (en) * 2020-03-25 2020-07-07 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for realizing cross-platform multi-language development
CN113626038A (en) * 2021-07-06 2021-11-09 曙光信息产业(北京)有限公司 Code conversion method, device, equipment and storage medium

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
JAMES369: "跨语言之间的调用,原理是什么?", 《HTTPS://WWW.V2EX.COM/T/731019》 *
头条用户: "不同编程语言的程序可不可以通过接口相互调用?", 《HTTPS://WUKONG.TOUTIAO.COM/QUESTION/6726330051781984526/》 *
知乎用户: "不同编程语言的程序可不可以通过接口相互调用?", 《HTTPS://WWW.ZHIHU.COM/QUESTION/340466938》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116048845A (en) * 2023-02-07 2023-05-02 之江实验室 Data processing method and device, storage medium and electronic equipment

Also Published As

Publication number Publication date
CN113934407B (en) 2022-06-07

Similar Documents

Publication Publication Date Title
US10678522B1 (en) Compiler and method for compiling business rules for a serverless runtime environment
JP6912583B2 (en) Service processing method and equipment
US8191042B2 (en) Continuation based declarative definition and composition
WO2020238277A1 (en) Access method based on h5 access mode, access assembly thereof and mobile terminal
CN108874372B (en) Scale-based block chain contract implementation method and system
CN110390213B (en) Security deployment method and system for intelligent contract under block chain network environment
CN110992188B (en) Transaction processing method, device and equipment
WO2024045382A1 (en) Implementation of reflective mechanism in blockchain
CN113688186B (en) Intelligent contract execution method, engine and block link point
CN113934407B (en) Method, device, medium and computing equipment for calling interfaces among different language codes
US20230367568A1 (en) Fast compiling source code without dependencies
CN111768183B (en) Method for executing intelligent contract, block chain node and storage medium
KR100297633B1 (en) Method and computer program product for client / server computing that supports both recoverable and non-recoverable clients
CN116541497A (en) Task type dialogue processing method, device, equipment and storage medium
CN108733432B (en) Method for realizing private method in programming environment, calling method and device thereof
CN112181378A (en) Method and device for realizing business process
CN110018831B (en) Program processing method, program processing apparatus, and computer-readable storage medium
CN111459573A (en) Method and device for starting intelligent contract execution environment
CN110022351B (en) Service request processing method and device
Ceccato et al. Adding distribution to existing applications by means of aspect oriented programming
US8572585B2 (en) Using compiler-generated tasks to represent programming elements
US20210182041A1 (en) Method and apparatus for enabling autonomous acceleration of dataflow ai applications
US11314496B2 (en) Ultra-fast install and update of an operating system
US20220066759A1 (en) Thread-local return structure for asynchronous state machine
EP4196874A1 (en) Representing asynchronous state machine in intermediate code

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40066375

Country of ref document: HK