Function packaging loading method, device, electronic device and storage medium

Through the function packaging loading method, the problem of UDF compatibility between different computing engines is solved, seamless migration and stability improvement are achieved, and the complexity of business switching between computing engines is simplified.

CN118331633BActive Publication Date: 2024-09-17TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410756800.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-09-17
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

There are compatibility issues with custom functions (UDFs) between different computing engines, which causes businesses to invasively modify the code when switching computing engines, increasing migration complexity and reducing stability.

Method used

Using the function packaging loading method, by parsing the tasks to be executed, querying the target custom function in the existing function collection, and constructing a temporary custom function that conforms to the computing engine UDF protocol, the function implementation class is loaded through the custom function wrapper to ensure compatibility and stability.

Benefits of technology

It achieves shielding the differences between different computing engines without intrusive modification of the engine code, reduces the complexity of business migration, improves the stability during the computing engine switching process, and ensures stability during the change of business computing requirements. consistency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118331633B
    Figure CN118331633B
Patent Text Reader

Abstract

The present application relates to the field of computer technology, and in particular to a function packaging and loading method, device, electronic device and storage medium, which are used to provide a unified custom function packaging and loading method for an object, reduce the complexity of business migration, and improve the stability of business operation. The method includes: after receiving the task to be executed triggered by the object, the task to be executed is analyzed and parsed; if it is determined that the task to be executed contains a target custom function, then query whether the target custom function exists in the existing function set; if the target custom function is found, a temporary custom function corresponding to the target custom function is constructed according to the custom function protocol of the computing engine; after loading the corresponding function implementation class according to the input parameters of the temporary custom function through the custom function wrapper, the temporary custom function is executed through the evaluation method of the function implementation class to obtain the execution result corresponding to the target custom function.
Need to check novelty before this filing date? Find Prior Art

Description

Background Art

[0002] In the field of big data computing, in order to meet different needs, more and more online analytical processing (OLAP) engines have emerged, such as Presto, Trino, StarRocks, etc. They use various acceleration methods to greatly improve the offline analysis and computing speed of massive data.

[0003] However, with the development of the business, the efficiency of some computing engines can no longer keep up with the development needs of the business. For example, a certain business used Hive (day level) as the computing entry point before. After a while, it switched to Spark (hour level) due to timeliness requirements. Later, it was felt that it needed to be faster, so it used Presto (minute level). Now, real-time computing is required, so StarRocks (second level) is selected as the computing system.

[0004] As timeliness requirements become increasingly stringent, it is necessary to constantly switch to computing engines with higher timeliness. However, since computing engines with different architectures are often not compatible with each other's user-defined functions (UDF), it is necessary to modify the functions in the business structured query language (SQL) to use the new engine. In the case of differences, it is also necessary to invasively modify the engine code, such as starting the index of array access (array) and string truncation (substr) operations from 0, which greatly increases the complexity of business migration and reduces the stability of business operations.

[0005] Therefore, it is urgent to solve the problem of how to shield the differences between different computing engines and provide a unified UDF usage method for objects without intrusively modifying the engine code. Summary of the invention

[0006] The embodiments of the present application provide a function packaging and loading method, device, electronic device and storage medium, which are used to shield the differences between different computing engines without intrusively modifying the engine code, and provide a unified custom function packaging and loading method for objects, so as to reduce the complexity of business migration and improve the stability of business operation.

[0007] A function packaging loading method provided in an embodiment of the present application includes:

[0008] After receiving the pending tasks triggered by the object, the pending tasks are analyzed;

[0009] Determining that the task to be executed includes a target user-defined function, querying whether the target user-defined function exists in the existing function set;

[0010] If the target custom function is found, constructing a temporary custom function corresponding to the target custom function according to the custom function protocol of the computing engine;

[0011] After loading the corresponding function implementation class according to the input parameters of the temporary custom function via the custom function wrapper, the temporary custom function is executed through the evaluation method of the function implementation class to obtain the execution result corresponding to the target custom function.

[0012] An embodiment of the present application provides a function packaging loading device, including:

[0013] A parsing and analyzing unit, configured to parse and analyze the tasks to be executed after receiving the tasks to be executed triggered by the objects;

[0014] A query unit, used for determining whether the task to be executed includes a target user-defined function, and then querying whether the target user-defined function exists in the existing function set;

[0015] A construction unit, configured to construct a temporary custom function corresponding to the target custom function according to the custom function protocol of the computing engine if the target custom function is found;

[0016] The packaging loading unit is used to load the corresponding function implementation class according to the input parameters of the temporary custom function through the custom function wrapper, execute the temporary custom function through the evaluation method of the function implementation class, and obtain the execution result corresponding to the target custom function.

[0017] Optionally, the construction unit is specifically used for:

[0018] According to the custom function protocol of the computing engine, construct a temporary custom function with empty input parameters;

[0019] The first input parameter of the temporary custom function is set to a string type, and the function name of the target custom function is written in the form of a string;

[0020] The input parameters of the target user-defined function are sequentially used as other input parameters after the function name to obtain a temporary user-defined function corresponding to the target user-defined function.

[0021] Optionally, the packaging loading unit is further used for:

[0022] Before executing the temporary user-defined function through the evaluation method of the function implementation class, converting the input parameters of the temporary user-defined function from the data types supported by the calculation engine to the target data types;

[0023] Verify the converted input parameters to ensure that the input parameters conform to the data types supported by the target data source;

[0024] After obtaining the execution result corresponding to the target custom function, the execution result is converted from the target data type to a data type supported by the computing engine.

[0025] Optionally, the packaging loading unit is specifically used for:

[0026] Determine whether the current thread can query the corresponding function implementation class according to the input parameters of the temporary custom function;

[0027] If it is determined that the current thread can query the corresponding function implementation class, then directly load the function implementation class;

[0028] If it is determined that the current thread cannot query the corresponding function implementation class, the relevant thread-level class loader is started to reload the function implementation class.

[0029] Optionally, the packaging loading unit is further used for:

[0030] Before executing the temporary user-defined function through the evaluation method of the function implementation class, determining the function type of the temporary user-defined function;

[0031] If the temporary user-defined function corresponds to the target function type, the temporary user-defined function is converted into a predefined unified type, so as to execute the temporary user-defined function using a unified function execution logic.

[0032] Optionally, the existing function set includes an engine built-in function subset, an engine custom function subset and a wrapper registered function subset; then the query unit is specifically used to:

[0033] If a function namespace specified for the target user-defined function is used, the function namespace is used as a prefix, the function name and input parameters of the target user-defined function are concatenated, and then a query is made as to whether the target user-defined function exists in the registered function subset of the wrapper;

[0034] If the function namespace is not used, then according to the function name and input parameters of the target user-defined function, it is queried in the existing function set whether the target user-defined function exists.

[0035] Optionally, the query unit is specifically used for:

[0036] If it is specified to search in the registered function subset of the wrapper first, then according to the function name and input parameters of the target user-defined function, it is searched whether the target user-defined function exists in the registered function subset of the wrapper;

[0037] If it is not specified to prioritize searching in the registered function subsets of the wrapper, then the function subsets included in the existing function set are searched in turn according to the function name and input parameters of the target custom function and in the specified priority order.

[0038] Optionally, the query unit is specifically used for:

[0039] If the target user-defined function exists in the engine built-in function subset, it is determined that the target user-defined function is found; if not, the search continues in the engine user-defined function subset;

[0040] If the target custom function exists in the engine custom function subset, determine that the target custom function is found; if not, continue to search in the wrapper registered function subset;

[0041] If the target user-defined function exists in the registered function subset of the wrapper, it is determined that the target user-defined function is found; if not, it is determined that the target user-defined function is not found.

[0042] Optionally, the query unit is specifically used for:

[0043] If the target user-defined function exists in the registered function subset of the wrapper, determining that the target user-defined function is found;

[0044] If it does not exist, no further search is performed in the engine built-in function subset or the engine custom function subset to determine that the target custom function is not found.

[0045] Optionally, the device further comprises:

[0046] A registration unit is used to write the function implementation class of the custom function registered by the object into a preset dictionary by static registration; wherein the key in the preset dictionary is the function name and the value is the function implementation class, and the preset dictionary is used for function query inside the custom function wrapper to query the function implementation class of the custom function according to the function name.

[0047] Optionally, the device further comprises:

[0048] A configuration unit is used to pre-start the relevant functions of the custom function wrapper in the computing engine.

[0049] An electronic device provided by an embodiment of the present application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the above-mentioned function packaging loading methods.

[0050] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any one of the above-mentioned function packaging and loading methods.

[0051] An embodiment of the present application provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of any one of the above-mentioned function packaging loading methods.

[0052] The beneficial effects of this application are as follows:

[0053] The embodiment of the present application provides a function packaging loading method, device, electronic device and storage medium. After receiving the task to be executed triggered by the object, the computing engine in the present application does not directly load the target custom function contained in the task to be executed, but queries the function in the existing function set. After determining that the function can be called normally, a temporary custom function that complies with the computing engine UDF protocol is constructed to ensure compatibility with the computing engine. On this basis, a temporary custom function is used as an intermediary, and the target custom function is loaded through a custom function wrapper as a unified interface package. This method only needs to package the user's existing Hive UDF, and then through the UDF protocol of different computing engines, the original UDF function of the object can be guaranteed to be loaded into different computing engines. In the business migration scenario, this method loads the custom function that the object has been accustomed to using into the new computing engine without intrusively modifying the engine code, so as to achieve the purpose of non-sensing migration of the business and improve the stability of the business in the process of switching computing engines.

[0054] In summary, the present application can solve the function compatibility problem between heterogeneous computing engines, shield the function differences between different computing engines, and enable tasks to be executed with the same function name to run on different computing engines, thereby meeting the computing needs of different business scenarios, reducing the complexity of task switching between different computing engines, and ensuring stability during changes in business computing needs.

[0055] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0057] Figure 1 A schematic diagram of an application scenario in an embodiment of the present application;

[0058] Figure 2 A flowchart of an implementation method of a function packaging loading method provided in an embodiment of the present application;

[0059] Figure 3 A schematic diagram of a function packaging and loading process of a computing engine in an embodiment of the present application;

[0060] Figure 4 A schematic diagram of an existing function set in an embodiment of the present application;

[0061] Figure 5 A logic diagram of a function query in an embodiment of the present application;

[0062] Figure 6 A flowchart of a function query method in an embodiment of the present application;

[0063] Figure 7 A schematic diagram of a specific implementation logic of a function packaging loading in an embodiment of the present application;

[0064] Figure 8 A multi-threaded execution logic diagram in an embodiment of the present application;

[0065] Fig. 9 A schematic diagram of a type conversion in an embodiment of the present application;

[0066] Fig.10 A schematic diagram of the composition structure of a function packaging loading device in an embodiment of the present application;

[0067] Fig.11 A schematic diagram of a hardware structure of an electronic device to which an embodiment of the present application is applied;

[0068] Fig.12 The present invention is a schematic diagram of the hardware structure of another electronic device to which the embodiments of the present application are applied. DETAILED DESCRIPTION

[0069] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.

[0070] The following is an introduction to some concepts involved in the embodiments of the present application.

[0071] Computing engine: A distributed computing system specially designed to efficiently process large amounts of data computing tasks. It supports access to different types of data sources through customized connectors and aggregates data for joint analysis. It provides the ability to perform operations such as data query, analysis, transformation, and aggregation, and is an indispensable technical component in the fields of big data processing, data warehouse, business intelligence, and artificial intelligence. Its main goal is to process large amounts of data quickly, accurately, and flexibly to support the needs of various data-intensive applications.

[0072] SQL: is a computer language used to store, retrieve, and modify data stored in relational data sources; data sources are systems used to store and process data, such as traditional relational databases (MySQL), object-relational databases (PostgreSQL), clickstream data sources (ClickStream Data Ware House, ClickHouse), etc., or data warehouse tools (Hive) of big data NoSQL systems, distributed data sources (Hadoop Database, HBase), distributed search (Elasticsearch), etc.

[0073] Massive Parallel Process (MPP): is a server classification method, generally referring to a server system built with multiple computing nodes. When executing a task, it can be split into multiple computing nodes for execution, and then the results are aggregated and returned to the user.

[0074] Hive: It is a data source that stores data on the Hadoop Distributed File System (HDFS), and it is also a distributed computing engine based on the MapReduce framework.

[0075] Presto: In technology and computing, Presto is a memory-based MPP distributed SQL execution engine that is used to enable fast interactive analysis of large-scale data sets (e.g., more than 250PB).

[0076] StarRocks: An extremely fast MPP OLAP computing engine for data lake scenarios. It is designed to handle complex real-time OLAP queries, providing sub-second query response times while supporting high concurrency. StarRocks integrates storage and computing, using technologies such as columnar storage and index acceleration, and is suitable for big data analysis scenarios such as ad hoc queries and interactive analysis.

[0077] Custom functions are functions designed and implemented by developers according to specific needs in programming. They allow programmers to encapsulate reusable code blocks to implement specific functions and can be called in multiple places in the program, thereby improving the reusability, maintainability and readability of the code. Custom functions can have many forms, including but not limited to accepting input parameters, returning processing results, performing specific tasks, etc. Its basic structure usually includes function definition (including function name, parameter list, function body) and function call.

[0078] Custom function wrapper: used to encapsulate user-defined logic into a format required by a specific framework, so as to efficiently call and manage these custom functions during query execution. For example, the custom function wrapper can be used to adapt user-defined functions to the standard interface or execution model of a specific data processing engine.

[0079] Evaluate method: In computer science, the evaluation method of a function is the method used in the internal implementation of the function to process the input parameters and generate the output results. The evaluation method is usually executed when the function is called. It receives the input parameters of the function and calculates according to the internal logic of the function to generate the output results of the function. The implementation of the evaluation method is usually closely related to the specific function of the function. It can perform various operations such as mathematical operations, string processing, data conversion, conditional judgment, etc. The output result of the evaluation method can be a simple single value or a complex structured data such as an array, tuple, dictionary, etc. In programming languages, the evaluation method is usually used as part of the function to implement the function's functionality. When the function is called, the evaluation method is automatically executed to process the input parameters of the function and generate the output results. This process is usually performed transparently by the function caller, who only needs to provide the input parameters of the function without having to care about the implementation details of the function.

[0080] Temporary custom functions: functions that are quickly defined and used in a specific context, especially to meet one-time or short-term needs, without the need to formally organize them into a code base. Such functions are improvised to handle a specific problem, calculate or transform data, and may not be retained or reused for a long time.

[0081] Function namespace: refers to an independent storage area allocated for variables and parameters defined within a function during program execution.

[0082] In the embodiment of the present application, the function packaging and loading process is designed based on cloud technology, big data, cloud computing, etc.

[0083] Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and network within a wide area network or local area network to achieve data computing, storage, processing, and sharing.

[0084] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, image websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0085] Big data refers to a collection of data that cannot be captured, managed, and processed by conventional software tools within a certain time frame. It is a massive, high-growth, and diverse information asset that requires new processing models to have stronger decision-making power, insight discovery, and process optimization capabilities. With the advent of the cloud era, big data has also attracted more and more attention. Big data requires special technologies to effectively process large amounts of data within a tolerable time frame. Technologies suitable for big data include large-scale parallel processing databases, data mining, distributed file systems, distributed databases, cloud computing platforms, the Internet, and scalable storage systems.

[0086] In the embodiments of the present application, there is an inseparable connection between the computing engine and big data. The two are interdependent and mutually reinforcing, and together constitute the basic architecture of modern data processing and analysis. Specifically, big data refers to data sets with huge data volume, wide variety, fast generation speed and relatively low value density. Its processing and analysis face challenges that are difficult for traditional data processing technologies to cope with, such as storage, computing, real-time, complex queries, etc. Therefore, big data processing urgently needs a computing engine with characteristics such as distributed processing, elastic expansion, efficient data access and processing, support for complex queries and analysis, and real-time or near real-time processing capabilities.

[0087] Computing engines are software systems designed and optimized to meet the challenges of big data processing. They provide key support for big data processing and analysis, including data storage and management, data cleaning and transformation, batch processing and interactive query, stream processing and real-time analysis, data mining and machine learning.

[0088] In summary, the relationship between big data and computing engines is one of demand and supply, challenge and solution. The characteristics and needs of big data have given rise to powerful and flexible computing engine technology, while computing engines provide solid support for the processing, analysis and application of big data, and together promote the widespread application of data-driven decision-making and innovation.

[0089] In addition, the computing engine in this application is closely related to big data. Specifically, cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, so that various application systems can obtain computing power, storage space and information services as needed. The network that provides resources is called the "cloud". The resources in the "cloud" are infinitely expandable in the eyes of users, and can be obtained at any time, used on demand, expanded at any time, and paid for by use.

[0090] As a cloud computing basic capability provider, a cloud computing resource pool (referred to as a cloud platform) will be established, generally referred to as an Infrastructure as a Service (IaaS) platform, in which various types of virtual resources are deployed for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.

[0091] According to the logical function division, the Platform as a Service (PaaS) layer can be deployed on the IaaS layer, and the Software as a Service (SaaS) layer can be deployed on the PaaS layer, or SaaS can be directly deployed on IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is a variety of business software, such as web portals, SMS mass senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.

[0092] As the core component of big data processing, the computing engine can be directly deployed and managed by users at the IaaS level, provided to users as part of the PaaS platform, or used as a processing engine in the background of SaaS applications.

[0093] The design concept of the embodiment of the present application is briefly described below:

[0094] In the field of big data computing, in order to meet different needs, more and more OLAP engines have emerged, such as Presto, Trino, StarRocks, etc. They use various acceleration methods (such as MPP) to greatly improve the offline analysis and computing speed of massive data.

[0095] However, with the development of the business, the efficiency of some computing engines can no longer keep up with the development needs of the business. For example, a certain business used Hive (day level) as the computing entry point before. After a while, it switched to Spark (hour level) due to timeliness requirements. Later, it was felt that it needed to be faster, so it used Presto (minute level). Now, real-time computing is required, so StarRocks (second level) is selected as the computing system.

[0096] From the above example, we can see that as the business develops, different computing engines are selected due to different timeliness requirements. However, the business needs to spend a lot of migration costs in the process of switching computing engines, such as modifying SQL syntax, UDF function adaptation, etc. Among them, how to ensure the compatibility of UDF in multiple computing engines is a relatively important issue that affects the stability and complexity of migration.

[0097] As the de facto standard in the field of metadata storage, Hive is used by many business clusters for data, metadata, and UDF. Most new OLAP engines are compatible with the reading and writing of data and metadata, allowing businesses to use new technologies to meet higher timeliness requirements. However, due to different architectures, computing engines are often not compatible with each other's UDFs, which requires modifying functions in business SQL to use new engines, greatly increasing the complexity of business migration and reducing the stability of business operations.

[0098] To solve this problem, related technologies, such as Presto, have their own unique UDF protocols, so existing Hive UDFs cannot be used directly for calculations. To solve this problem, some commercial companies have made intrusive modifications to function differences, such as starting the index of array access (array) and string truncation operations (substr) from 0. Similarly, StarRocks also has its own set of UDF protocols and cannot directly use existing UDFs. Currently, the official only supports Hive Bitmap functions, while other functions require users to re-implement them based on StarRocks' UDF framework.

[0099] In summary, there are compatibility issues between UDFs of different computing engines. Since each engine has its own unique UDF protocol, it is often not feasible to use UDFs directly across engines. To solve this problem, commercial companies may adopt invasive modification methods, and when users face UDFs that are not officially supported, they need to re-implement them according to the UDF framework of the target engine. This highlights the challenges of UFD development and migration when processing data in a multi-computing engine environment, as well as the need for cross-engine UDF compatibility solutions.

[0100] In view of this, the embodiment of the present application proposes a function packaging loading method, device, electronic device and storage medium. Because the computing engine in the present application does not directly load the target custom function contained in the task to be executed after receiving the task to be executed triggered by the object, but queries the function in the existing function set, and after determining that the function can be called normally, constructs a temporary custom function that complies with the computing engine UDF protocol to ensure compatibility with the computing engine. On this basis, a temporary custom function is used as an intermediary, and the target custom function is loaded through a custom function wrapper as a unified interface packaging. This method only needs to package the user's existing Hive UDF, and then through the UDF protocol of different computing engines, the original UDF function of the object can be guaranteed to be loaded into different computing engines. In the business migration scenario, this method loads the custom function that the object has been accustomed to using into the new computing engine without intrusively modifying the engine code, so as to achieve the purpose of non-sensing migration of the business and improve the stability of the business in the process of switching computing engines.

[0101] In summary, the present application can solve the function compatibility problem between heterogeneous computing engines, shield the function differences between different computing engines, and enable tasks to be executed with the same function name to run on different computing engines, thereby meeting the computing needs of different business scenarios, reducing the complexity of task switching between different computing engines, and ensuring stability during changes in business computing needs.

[0102] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.

[0103] like Figure 1 As shown, it is a schematic diagram of an application scenario in an embodiment of the present application. The application scenario diagram includes a terminal device 110 and a server 120.

[0104] In the embodiment of the present application, the terminal device 110 includes but is not limited to mobile phones, tablet computers, laptop computers, desktop computers, e-book readers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals and other devices; the terminal device may be installed with a relevant client, which may be software (such as a browser), or a web page, a small program, etc. The server 120 is a background server corresponding to the software or web page, small program, etc., or a server specifically used for function packaging and loading, which is not specifically limited in the present application. The server 120 may 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 (CDN), and big data and artificial intelligence platforms.

[0105] It should be noted that the computing engine in the embodiment of the present application can be deployed on the terminal device 110 or on the server 120.

[0106] In some cases, the computing engine may be deployed on the terminal device 110 (such as a smart phone, an embedded device, an edge computing node, etc.) to perform local function packaging and data processing. In this case, the function packaging loading process occurs directly in the computing engine of the terminal device 110 without relying on the remote server 120. This scenario is common in application scenarios with high real-time requirements, sensitive data privacy, or limited network conditions.

[0107] More commonly, the computing engine is deployed in the server 120 (such as a cloud server or a data center). The terminal device 110 sends data and computing requests to the computing engine on the server 120 through the network, and the server 120 completes the function packaging and loading and subsequent computing tasks. This method fully utilizes the powerful computing power and rich storage resources of the server 120, and is suitable for processing large-scale and complex computing tasks.

[0108] In summary, the function packaging loading method in each embodiment of the present application can be executed by an electronic device deployed with a computing engine, and the electronic device can be a terminal device 110 or a server 120, that is, the method can be executed by the terminal device 110 or the server 120 alone, or can be executed jointly by the terminal device 110 and the server 120.

[0109] Taking server 120 as the execution subject as an example, a computing engine is deployed on the server 120, and the relevant functions of the custom function wrapper are started inside the computing engine. After the computing engine receives the task to be executed triggered by the object, it first parses and analyzes the task to be executed; if it is analyzed that the task to be executed contains the target custom function, it is queried whether the target custom function exists in the existing function set; if the target custom function is queried, a temporary custom function corresponding to the target custom function is constructed according to the custom function protocol of the computing engine; then, the computing engine calls the started custom function wrapper, and after the custom function wrapper loads the corresponding function implementation class according to the input parameters of the temporary custom function, the temporary custom function is executed through the evaluation method of the function implementation class to obtain the execution result corresponding to the target custom function.

[0110] In an optional implementation, the terminal device 110 and the server 120 may communicate with each other via a communication network.

[0111] In an optional implementation, the communication network is a wired network or a wireless network.

[0112] It should be noted that Figure 1 The figure is only an example. In fact, the number of terminal devices and servers is not limited and is not specifically limited in the embodiments of the present application.

[0113] In an embodiment of the present application, when there are multiple servers, the multiple servers can form a blockchain, and the servers are nodes on the blockchain; as in the function packaging and loading method disclosed in the embodiment of the present application, the relevant data involved can be saved on the blockchain, for example, function name, input parameters, namespace, UDF protocol, preset dictionary, etc.

[0114] In addition, the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving and other scenarios, and can be specifically applied to various data processing, analysis, decision support and business migration environments related to these scenarios.

[0115] In business migration scenarios, especially when you need to switch from one computing engine to another (such as migrating from Hadoop MapReduce to Spark, or from Presto to Trino, etc.), querying and executing user-defined functions is a key step in ensuring business continuity and functional compatibility. The following are several common business migration scenarios that reflect the importance of UDF query and execution when migrating between different computing engines:

[0116] Business migration scenario 1: Data analysis platform upgrade.

[0117] Enterprises may migrate from old data analysis platforms to new platforms due to performance bottlenecks, cost considerations, or new technology support. In this process, a large number of SQL queries and data pipelines that rely on specific UDFs for data preprocessing, feature engineering, or business logic calculations need to be seamlessly migrated.

[0118] Business migration scenario 2: Cloud service provider migration.

[0119] When an enterprise migrates a data warehouse or data lake from one cloud service provider to another (such as from AWS Athena to Google BigQuery or Azure Synapse), there may be differences in SQL and built-in functions between cloud platforms, and the original custom functions need to be re-registered or adapted to ensure that the business logic remains unchanged.

[0120] Business migration scenario three: hybrid cloud / multi-cloud strategy implementation.

[0121] When enterprises adopt a hybrid cloud or multi-cloud strategy, they may need to migrate data processing tasks between computing engines of different cloud service providers. For example, after processing data with AWS Glue ETL jobs, the resulting data is imported into Google Cloud Dataflow for further analysis. At this time, it is extremely important to ensure the compatibility and portability of UDFs across cloud environments.

[0122] Business migration scenario 4: Collaboration between edge computing and centralized processing.

[0123] In the Internet of Things (IoT) scenario, edge nodes may run lightweight computing engines (such as Apache Flink or Kafka Streams), while central data centers may use more powerful engines (such as Spark or Hadoop). The UDF involved in the business logic must be correctly executed at both the edge and the center to achieve seamless connection between preliminary data processing and in-depth analysis.

[0124] Business migration scenario 5: Data science and machine learning project migration.

[0125] When developing a model, data scientists may prototype it in a local environment (such as using Pandas UDFs) and then deploy the model to a production environment (such as using Spark MLlib). In this process, ensuring the consistency of custom transformation functions or feature extraction functions used in the model in different environments is the key to successful model migration.

[0126] Business migration scenario six: compliance and data privacy protection.

[0127] In scenarios involving sensitive data processing, enterprises may have developed specific UDFs to implement data desensitization, encryption, or privacy protection logic. During the migration process, these UDFs must be correctly implemented in the new computing engine to ensure continued compliance with data protection regulations and company policies.

[0128] From the above application scenarios, it can be seen that in the process of business migration, effectively managing and executing user-defined functions is an important part of ensuring business continuity, data processing logic consistency and improving migration efficiency.

[0129] The following describes the function packaging loading method provided by the exemplary embodiment of the present application in combination with the application scenarios described above and with reference to the accompanying drawings. It should be noted that the above application scenarios are only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this regard.

[0130] First of all, it should be noted that in the embodiment of the present application, before using the custom function wrapper to package and load the custom function, it is also necessary to pre-start the relevant functions of the custom function wrapper (such as Hive UDFWrapper) in the corresponding computing engine. For different computing engines, their usage methods are different, and the corresponding Hive UDFWrapper startup methods are also different. This article does not make specific restrictions, and the following are a few simple examples:

[0131] 1. Spark engine

[0132] In the Spark engine, you need to enable the Hive UDF Wrapper function through the following parameters:

[0133] spark.sql.hive.udf.enabled: This parameter indicates whether to use Hive UDF. In other words, this parameter can be used to control whether to enable Hive UDF support in Spark.

[0134] Specifically, when this parameter is set to true (i.e. spark.sql.hive.udf.enabled=true), Spark allows the use of registered Hive UDFs for query calculations. When this parameter is set to false (i.e. spark.sql.hive.udf.enabled=false), Spark will follow its own logic to process function calls and will not support Hive UDFs.

[0135] spark.sql.hive.udf.register.enabled: indicates whether to register an existing Hive UDF Wrapper. In other words, this parameter can be used to determine whether to register an existing Hive UDF Wrapper in Spark for use. Wrapper is usually used to adapt the Hive UDF interface to the Spark execution environment.

[0136] Specifically, when this parameter is set to true (i.e. spark.sql.hive.udf.register.enabled=true), it means that registration is enabled, so that Spark can recognize and use the existing Hive UDF Wrapper; when this parameter is set to false (i.e. spark.sql.hive.udf.register.enabled=false), it means that UDFWrapper is not used. In this case, even if spark.sql.hive.udf.enabled is true, Hive UDF cannot be used.

[0137] In summary, you need to set spark.sql.hive.udf.enabled=true and spark.sql.hive.udf.register.enabled=true. In this way, you can enable the Hive UDF Wrapper function in the Spark engine.

[0138] 2. Presto engine

[0139] Due to its plugin development style, Presto uses plugin mechanism to extend functions, including supporting Hive UDF. Therefore, in the Presto engine, to use Hive UDF function, you need to add hive.properties file in etc / function-namespace directory. This file tells Presto which plugin to use to load and manage Hive UDF. The file content is as follows:

[0140] function-namespace-manager.name=hive-functions: specifies the plug-in used to load Hive UDF. Specifically, this line of configuration specifies the use of the plug-in named hive-functions as the manager of Hive UDF. This plug-in is responsible for loading the wrapper of Hive UDF, registering it as a Presto plug-in, and providing a series of subsequent query, execution of Hive UDF and other functions.

[0141] In this way, Presto can seamlessly connect to and use Hive's UDF.

[0142] 3. StarRocks engine

[0143] In the StarRocks engine, you only need to add the following configuration on the FE side to enable the Hive UDF Wrapper function:

[0144] enable_udf=true: Indicates whether to enable the UDF function. This is a parameter of the StarRocks engine itself, which is used to turn on or off the entire UDF (including Hive UDF and other types of UDF) function. Only when it is set to true, StarRocks allows the use of its Java UDF framework to write and execute custom functions.

[0145] hive_udf_wrapper_url={udf_wapper url}: specifies the storage location of Hive UDF Wrapper. This URL can point to a Maven repository (for obtaining published wrapper libraries) or an HDFS path (for storing custom or private wrappers). StarRocks obtains and loads Hive UDF WRAPPER through this URL to support HiveUDF.

[0146] enable_hive_function=true: This is a session-level parameter that indicates whether the current session enables support for Hive Function. Set it to true through the SET command before executing the task, indicating that Hive UDF can be used in the current session. If you need to enable it globally, you may need to set the corresponding parameters in the engine configuration file.

[0147] In summary, the above content describes how to enable and configure Hive UDF Wrapper support in the three computing engines Spark, Presto, and StarRocks. Each computing engine has its own specific parameters and configuration methods, including enabling global UDF support, specifying the location and loading method of Hive UDF WRAPPER, and enabling HiveFunction support at the session level. By setting these parameters correctly, users can successfully use Hive UDFWrapper for data processing and analysis in their respective environments. Of course, the three types listed above are just simple examples. In addition, this application also supports enabling the Hive UDF Wrapper function by setting relevant parameters in other types of computing engines, which will not be repeated here.

[0148] In the above implementation, using global UDF support and configuring the Hive UDF wrapper can make the computing engine and Hive UDF seamlessly connected, ensuring that Hive UDF can work properly in non-Hive environments (such as Spark, Presto, Trino and other computing engines). In this way, users can use the same Hive UDF in different computing engines without rewriting or porting the code for each engine, which helps to achieve compatibility and interoperability across computing engines, simplify the migration and integration process, improve development and operation efficiency, maintain functional consistency, and enhance the scalability and future adaptability of the system. This lays the foundation for building a flexible, scalable, and easy-to-maintain big data processing environment.

[0149] Based on the above, different computing engines can use Hive UDF Wrapper to implement function packaging and loading according to their own UDF protocol after receiving the tasks to be executed triggered by the object. This process does not require invasive code modification. The specific implementation is as follows:

[0150] See also Figure 2 As shown, it is an implementation flow chart of a function packaging loading method provided in an embodiment of the present application. Taking the computing engine as the execution subject as an example, the specific implementation process of the method is as follows S21~S24:

[0151] S21: After receiving the task to be executed triggered by the object, the task to be executed is parsed and analyzed.

[0152] In the embodiment of the present application, the task to be executed specifically refers to an SQL query task input by an object (such as a user or an application program, etc.), and specifically, it may be a query of a user-defined function.

[0153] In the computing engine, querying user-defined functions and executing them is widely used in various data processing, analysis and decision support environments. Here are a few specific examples:

[0154] Query scenario 1: Data format conversion and standardization.

[0155] For example, users define custom functions to process data from different sources and in different formats, such as converting date formats, unifying currency units, cleaning up outliers, etc. When query tasks integrate heterogeneous data sources, they call these functions to ensure data consistency and comparability, providing high-quality data for subsequent analysis.

[0156] Query scenario 2: data privacy and security.

[0157] For example, users write custom functions for data desensitization, anonymization, or permission checking. When query tasks retrieve sensitive data, they must first call these functions to ensure data compliance output, such as replacing personal identifiers, implementing differential privacy technology, or verifying the visitor's permission level.

[0158] Query scenario three: geospatial analysis.

[0159] For example, users create custom geographic functions, such as calculating the distance between two points, determining whether a point is within a polygon, and aggregating data of nearby points. When query tasks process location data, they call these functions to perform spatial relationship queries or spatial aggregation analysis to support Geographic Information System (GIS) application requirements.

[0160] Query scenario four: text processing and natural language understanding.

[0161] For example, users have developed custom natural language processing (NLP) functions, such as sentiment analysis, keyword extraction, entity recognition, etc. When query tasks process large amounts of text data, these functions are called to perform text preprocessing and feature extraction, providing support for applications such as content recommendation and knowledge graph construction.

[0162] Query scenario five: machine learning model application.

[0163] For example, users can encapsulate trained machine learning models into custom functions, and query tasks can call these functions to predict or transform features of new data at runtime. For example, credit scoring models are used for risk assessment, image classification models are used for content review, and clustering algorithms are used for customer segmentation.

[0164] It should be noted that the above application scenarios are just simple examples. In addition, other application scenarios are also applicable to the embodiments of the present application, such as other specific business needs, data processing tasks, and advanced analysis scenarios, etc., which are not specifically limited here.

[0165] For example, in a certain scenario, an object (such as a user or application) submits a SQL query task to the computing engine. The task is expressed in the form of a select statement, such as the task to be executed: select hive.function(arg1). The function named hive.function is called, and the parameter arg1 is passed in.

[0166] In the embodiment of the present application, the object can submit the task to be executed through API calls, command line tools, user interfaces, etc.

[0167] like Figure 3 As shown, it is a schematic diagram of a function packaging loading process of a computing engine in an embodiment of the present application. Figure 3 S31 in the figure indicates a task to be executed, which is an SQL query task input by a user; S32 indicates some functional modules in the computing engine except the UDF Wrapper, including a parsing module, an analysis module, a function access calling module and a temporary custom function construction module; S33 indicates the UDF Wrapper functional module.

[0168] The following is an introduction to the overall process of function packaging and loading in the computing engine based on the above examples.

[0169] by Figure 3 As shown in the example, after the computing engine receives the task to be executed (select hive.function(arg1)), it first parses the task and then analyzes the task. The parsing process mainly converts the SQL text into an internal data structure and identifies the various components of the query statement. The analysis process mainly checks the grammatical correctness of the SQL statement, determines the meaning of the identifier, performs type checking and query optimization, and prepares the execution plan.

[0170] Specifically, the task is first parsed, for example, the SQL text select hive.function(arg1) is converted into an internal data structure (such as an abstract syntax tree, abbreviated as AST). During the parsing process, the computing engine identifies the various components of the query statement (such as the select list, table name, column name, expression, function call, etc.) and constructs the corresponding AST node.

[0171] Next comes analysis, also known as semantic analysis or query optimization. In this phase, the computing engine checks the syntactic correctness of the SQL statement, determines the meaning of each identifier (such as the actual pointer of the function name, table name, and column name), performs type checking, and possible query optimization (such as predicate pushdown, predicate elimination, selection of appropriate join algorithms, physical execution plan generation, etc.). The analysis phase ensures that the query is logically correct and prepares the best execution plan for the execution phase.

[0172] S22: If it is determined that the task to be executed includes a target user-defined function, it is then queried whether the target user-defined function exists in the existing function set.

[0173] The target user-defined function refers to any user-defined function (UDF). UDF is a special function defined by the user and used to process specific data types or implement specific business logic. Specifically, UDF includes but is not limited to: user-defined scalar function (UDSF), user-defined aggregation function (UDAF), user-defined table function (UDTF), etc.

[0174] Among them, UDSF is a function type used to process a single data item and return a single result, that is, one input and one output. They are mainly used to perform simple calculations, conversions, or judgments on a single row of data, such as string concatenation, date format conversion, mathematical operations, etc. For example, convert a string to uppercase letters.

[0175] UDAF is a function type used to process multiple data items and return a single result, that is, multiple input and one output. Common examples include custom average calculations, complex counting conditions, custom quantile calculations, etc. For example, calculate the average value of a column.

[0176] UDTF is a function type used to convert one input into multiple outputs, that is, one input and multiple outputs (such as lateral viewexplode()). They can be used to generate a new set of data rows, such as dynamically generating a series of rows based on input parameters, or splitting a single row of data into multiple rows.

[0177] In addition to the common UDF types mentioned above, some specific computing engines may also support other types of user-defined functions, such as window functions. Users can sometimes customize window functions to handle complex calculations within a data window. Window functions can apply a calculation to each row in a partition of a data set, while taking into account the rows around the row (such as adjacent rows, all rows in the same group, etc.).

[0178] Still with the above Figure 3 Take the task select hive.function(arg1) to be executed as an example. When the user task is analyzed to contain the function hive.function(arg1), since this is a UDF and computing engines with different architectures are often not compatible with each other's UDFs, this application is delegated to a component that specializes in processing UDFs, namely the user-defined function wrapper (full name: user-defined function wrapper, UDF Wrapper) for processing.

[0179] In the embodiment of the present application, UDF Wrapper is introduced as a unified interface, and the user's existing Hive UDF only needs to be packaged and then loaded into different computing engines through the UDF protocols of different computing engines.

[0180] UDF Wrapper is a class or module used to encapsulate and manage UDFs. It provides a unified entry point for calling user-defined UDF functions. This entry point is usually a method, such as the evaluate method, which is responsible for passing input parameters to the user-defined UDF function and converting the function's execution result into the data type inside the calculation engine.

[0181] In the embodiment of the present application, for the computing engine, the relevant functions of UDF Wrapper can be started in the computing engine in advance through parameter settings. On this basis, if the target custom function is found in the existing function set, it means that the function can be correctly identified and called, and dynamic function packaging loading can be realized based on UDF Wrapper in the future.

[0182] The following is a detailed description of the function query process in S22:

[0183] In the embodiment of the present application, the existing function set includes existing functions corresponding to the computing engine, including engine built-in functions and engine custom functions. In addition, the custom function wrapper can be understood as a functional module in the computing engine because it also includes wrapper registered functions. Therefore, the existing function set can be divided into an engine built-in function subset, an engine custom function subset, and a wrapper registered function subset.

[0184] like Figure 4 As shown, it is a schematic diagram of an existing function set in an embodiment of the present application, wherein S41 represents the existing function set, and S41 can be further divided into three parts: S411: engine built-in function subset, S412: engine custom function subset, S413: wrapper registered function subset.

[0185] Specifically, the subset of engine built-in functions includes functions pre-defined inside the computing engine (such as database management systems, data analysis engines, etc.), which can be referred to as engine built-in functions. These functions are usually used to perform common computing tasks, such as mathematical operations, string processing, date and time operations, etc. These functions are usually provided by the engine itself and do not need to be written by users themselves. They can be used directly in query statements.

[0186] In actual applications, the engine's built-in functions are usually used to simplify the writing of query statements and improve the efficiency and accuracy of queries. Users can use these functions to perform complex computing tasks without writing complex code.

[0187] The subset of engine UDFs is included in the computing engine. These functions are user-defined functions, which can be referred to as engine UDFs. These functions are usually used to perform specific computing tasks to meet the needs of users in specific scenarios.

[0188] The subset of registered wrapper functions includes those UDFs that have been correctly registered and can be recognized and called by the computing environment using UDF Wrapper. These functions can be referred to as registered wrapper functions. In an environment using UDFWrapper, users need to register their own UDFs first to make them "registered functions" before they can be called by the computing engine later.

[0189] In practical applications, user-defined functions are often used to perform specific computing tasks to meet the needs of users in specific scenarios. Users can use these functions to perform complex computing tasks without writing complex code.

[0190] On this basis, the present application provides a flexible function query logic. An optional implementation method is to implement S22 according to the following process:

[0191] First, analyze whether it is necessary to use the function namespace (referred to as namespace) specified for the target custom function to query the function. There are two specific cases:

[0192] Case 1: If you need to use the function namespace specified for the target custom function, use the function namespace as a prefix, concatenate the function name and input parameters of the target custom function, and then query whether the target custom function exists in the subset of registered functions of the wrapper.

[0193] This situation is the function query method 1 in the embodiment of the present application: specifying the namespace. The use of the function namespace is crucial to solving the problem of duplicate function names. Functions with the same name but different implementations or functions can be distinguished by the namespace. For example, when there is a name conflict between a system built-in function and a user-defined function or an externally introduced function, by specifying the function namespace, the target function can be called accurately to avoid ambiguity.

[0194] Specifically, in the function query method 1 proposed in this application, it is first necessary to determine which namespace the target custom function of this query belongs to, such as the Hive default namespace, the namespace of a specific library, or the custom UDF namespace. Then, use the specified function namespace prefix to concatenate the function name and the function's input parameters for query.

[0195] For example: select hive.function(arg1), the corresponding function namespace is hive, the function name is function, and the input parameter is arg1. Based on these three pieces of information, you can query whether the same function exists in the Hive UDF in the UDF Wrapper. If the same function exists in the Hive UDF in the UDF Wrapper, it can be determined that the target custom function is found in the existing function set. Otherwise, it can be determined that the target custom function is not found in the existing function set.

[0196] In the above implementation, by specifying a namespace (such as Hive), the engine built-in functions, custom UDFs, and Hive UDFs in UDF Wrapper can be clearly distinguished to avoid function name conflicts and ensure that the calling intention is clear. This ensures that in the same task, the engine's existing functions and Hive UDFs in UDF Wrapper coexist without causing ambiguity. In addition, the engine built-in functions, custom UDFs, and Hive UDFs can be used simultaneously in the same query task, and each component operates independently without affecting each other, which enhances the modularity and scalability of the system.

[0197] like Figure 5 As shown, it is a logical diagram of a function query in an embodiment of the present application. In brief summary, Figure 5 That is, when using the function namespace (i.e., the above-mentioned case 1), the registered function subset of the wrapper is queried according to the function namespace, function name and input parameters. Specifically, the query method 1 (specifying the function namespace) is adopted. It is only necessary to query in the registered function subset of the wrapper. For the specific implementation method, please refer to the above-mentioned embodiment.

[0198] In the case where the function namespace is not used, that is, the following case 2, an existing function set is queried based on the function name and input parameters. In this case, according to whether it is specified to prioritize the query of the registered function subset of the wrapper, it can be further divided into query method 2 (adaptive query) and query method 3 (same name replacement). Among them, when it is not specified to prioritize the query of the registered function subset of the wrapper, query method 2 is adopted, which requires first querying the engine built-in function subset, then querying the engine custom function subset, and finally querying the registered function subset of the wrapper; when it is specified to prioritize the query of the registered function subset of the wrapper, query method 3 is adopted, and it is only necessary to query in the registered function subset of the wrapper. For specific implementation methods, please refer to the following embodiments.

[0199] Case 2: If the function namespace does not need to be used, query whether the target custom function exists in the existing function set based on the function name and input parameters of the target custom function.

[0200] This situation corresponds to the query method 2 and query method 3 when querying functions in the embodiment of the present application. Specifically, when querying functions according to function names and input parameters, since the existing function set can be divided into three categories: engine built-in function subsets, engine custom function subsets, and wrapper registered function subsets, based on situation 2, it can be further divided into the following two sub-situations according to whether to specify a certain type of function for priority query:

[0201] In the embodiment of the present application, depending on whether it is specified to prioritize the search in the subset of registered functions of the wrapper, it is divided into the following two sub-situations:

[0202] Subcase 1: If it is not specified to prioritize searching in the registered function subsets of the wrapper, then the function subsets included in the existing function set are searched in turn according to the function name and input parameters of the target custom function and in the specified priority order.

[0203] In an embodiment of the present application, if the function namespace is not specified for querying, and it is not specified to prioritize querying in the subset of functions registered in the wrapper, adaptive querying can be performed in the above three types of function subsets according to a certain priority order.

[0204] This situation is the second function query method in the embodiment of the present application: adaptive query. In the embodiment of the present application, adaptive query is a method for dynamically determining the function call path. It does not require the user to explicitly specify the namespace where the function is located, but automatically finds and executes the appropriate function version based on a set of predefined priority rules. This method simplifies the complexity of users when writing queries, while retaining a certain degree of flexibility and the possibility of performance optimization.

[0205] That is, without specifying the function namespace, the function name and input parameters are directly used for querying. The core of adaptive query lies in its priority order, that is, when there are functions with the same name, the system will decide which version of the function to use according to the established priority. An optional priority order is: engine built-in function subset > engine custom function subset > wrapper registered function subset. That is, the built-in functions of the engine are queried first, then the engine-specific user-defined functions, and finally the external or specific library UDF provided by the UDF Wrapper. This sorting logic is based on performance and control considerations. Built-in functions are usually optimized to provide better execution efficiency; while custom functions give users more customization space.

[0206] In this order, an optional specific implementation of the function query is as follows:

[0207] First, based on the function name and input parameters, query whether the target custom function exists in the engine built-in function subset; if the target custom function exists in the engine built-in function subset, determine whether the target custom function is found in the existing function set; if not, continue to query whether the target custom function exists in the engine custom function subset based on the function name and input parameters.

[0208] Similarly, if the target custom function exists in the engine custom function subset, it is determined that the target custom function is found in the existing function set; if not, based on the function name and input parameters, it is further queried whether the target custom function exists in the wrapper registered function subset.

[0209] Finally, if the target user-defined function exists in the registered function subset of the wrapper, it is determined that the target user-defined function is found; if not, it is determined that the target user-defined function is not found in the existing function set.

[0210] For example: select function(arg1), the function namespace is not specified, the function name is function, and the input parameter is arg1. In this case, the function query will have a certain priority order, as shown above, the default is engine built-in function > engine UDF > UDF Wrapper (the setting or adjustment of this priority order usually needs to be specified in the configuration file of the system or query execution environment). In this way, functions with the same name will give priority to the engine built-in or custom UDF instead of UDFWrapper. This can ensure performance as much as possible and also have a certain degree of flexibility.

[0211] In addition, it should be noted that in the embodiment of the present application, if the UDF Wrapper is not used, it can be turned off through parameters without any impact on the engine itself.

[0212] That is, although built-in or custom UDFs are used by default, the system usually provides configuration options to allow users or administrators to adjust the query order as needed, or to enable or disable function queries in the UDF Wrapper as needed. This means that if you want to change the default behavior for performance, security, or other reasons, you can do so by modifying the configuration.

[0213] In the above implementation, without specifying a namespace, the adaptive query mechanism can reduce errors caused by function naming conflicts, because the system will automatically select the most appropriate function to execute based on the priority, avoiding the confusion that may be caused by manually specifying the namespace. In this way, there is no need to explicitly specify the namespace, which can simplify the writing of query statements and meet the needs of different users and scenarios. In addition, adaptive queries are performed according to the default priority, giving priority to built-in functions or custom UDFs with better performance and less resource consumption, which is beneficial to overall performance optimization. Existing query statements and custom functions can continue to be used without modification, maintaining the backward compatibility of the system.

[0214] Subcase 2: If it is specified to search in the subset of registered functions of the wrapper first, then the target user-defined function is searched in the subset of registered functions of the wrapper based on the function name and input parameters of the target user-defined function.

[0215] In big data processing and data analysis scenarios, especially when using computing engines such as Hive and Spark, users often need to call various functions to process data. When there are multiple functions with the same name in the system, from different sources (such as engine built-in functions, user-defined functions (UDFs), or external functions introduced through UDF Wrappers), it is particularly important to efficiently and accurately select the correct function to execute.

[0216] Among them, the above sub-case three is the function query method three in the embodiment of the present application: replacement of the same name.

[0217] In this way, you need to explicitly specify a list of function names that give priority to using UDFWrapper in the configuration file of the system or query execution environment.

[0218] In this manner, an optional specific implementation of function query is as follows:

[0219] Query whether the target custom function exists in the registered function subset of the wrapper;

[0220] If the target user-defined function exists in the registered function subset of the wrapper, it is determined that the target user-defined function is queried; if it does not exist, it is no longer queried in the engine built-in function subset or the engine user-defined function subset, and it is determined that the target user-defined function is not queried.

[0221] Specifically, without specifying a namespace, you can use the function name and input parameters to query. However, functions with the same name will use UDF Wrapper first. By configuring the function name that gives priority to UDF Wrapper, the function registered by UDFWrapper will be used directly for calculation instead of the built-in or custom functions in the search engine.

[0222] Assume that a company uses a comprehensive data processing platform that integrates Hive and custom Python UDFs, and also introduces a set of high-performance image processing function libraries through UDF Wrapper. On this platform, there are two custom functions F with the same name: one is built-in by the platform and is used for basic image resizing; the other is a function in the advanced image processing library introduced through UDF Wrapper, which can achieve complex image recognition and enhancement functions.

[0223] To meet specific business requirements, for all queries that call function F, advanced image processing functions in the UDF Wrapper are preferred over built-in simple processing functions.

[0224] In this scenario, because the configuration specifies that functions in the UDF Wrapper are used first, you only need to query function F in the UDF Wrapper. If it is not found, there is no need to query other subsets.

[0225] In the above implementation, the priority of the function can be flexibly adjusted according to business needs without modifying the query statement or function code, which improves the adaptability and flexibility of the system. In addition, the use of UDF Wrapper can uniformly manage externally introduced functions, facilitate version control, performance optimization and function upgrades, and ensure the standardization and consistency of the code. In addition, the functions in UDF Wrapper are given priority because these functions are specially optimized or provide more advanced functions, which help improve the efficiency and quality of data processing.

[0226] like Figure 6 As shown, it is a flow chart of a function query method in an embodiment of the present application. Specifically, Figure 6 This section introduces the execution logic of the above three query methods from the perspective of timing. The query process is as follows:

[0227] S601: Query function.

[0228] S602: Determine whether to use the specified function namespace, if yes, execute step S608, otherwise, execute step S603.

[0229] S603: Determine whether to specify to prioritize the query wrapper registered function subset, if yes, execute step S608, otherwise, execute step S604.

[0230] S604: Determine whether it exists in the engine built-in function subset, if yes, execute step S605, otherwise, execute step S606.

[0231] S605: Use the function found in the built-in function subset of the engine.

[0232] S606: Determine whether it exists in the engine custom function subset, if yes, execute step S607, otherwise, execute step S608.

[0233] S607: Use the function found in the engine custom function subset.

[0234] S608: Determine whether the specific UDF function is enabled, if yes, execute step S609, otherwise execute step S610.

[0235] S609: Determine whether it exists in the specific UDF function subset, if yes, execute step S610, otherwise, execute step S611.

[0236] The specific UDF function subset is the registered function subset of the wrapper in this article.

[0237] S610: Use the function found in the specific UDF function subset.

[0238] S611: An exception is thrown.

[0239] Specifically, after receiving the task to be executed, the computing engine determines that the task to be executed indicates that a target custom function needs to be queried, and then first determines whether to use the function namespace specified for the target custom function, such as steps S601-S602.

[0240] If the specified function namespace is not used, it is further determined whether the priority query of the registered function subset of the wrapper is specified. If not (i.e., it is not specified whether the priority query of the registered function subset of the wrapper is specified), then corresponding to the above query method 2, the engine built-in function subset, the engine custom function subset and the registered function subset of the wrapper are queried in turn. If no result is found, an exception is thrown. For example, S603~S607 and S611 above.

[0241] If yes (i.e. specifying whether to query the registered function subset of the wrapper first), corresponding to the above query method 3, it is necessary to determine whether the specific UDF function (i.e. the function registered in the UDF wrapper) is enabled. If it is enabled, directly query whether the specific UDF function exists in the specific UDF function (i.e. the function registered in the UDF wrapper, i.e. the registered function subset of the wrapper in this article). If it exists, use the function queried in the specific UDF function; otherwise, throw an exception. As described in S603, S608~S611 above.

[0242] If the specified function namespace is used, corresponding to the above query method 1, further determine whether the specific UDF function (i.e., the function registered in the UDF wrapper) is enabled. If it is enabled, directly query whether the specific UDF function exists in the specific UDF function (i.e., the function registered in the UDFwrapper, that is, the subset of the wrapper registered functions in this article). If it exists, use the function queried in the specific UDF function; otherwise, throw an exception. As described in S608~S611 above.

[0243] in, Figure 3 The function access and call module in the example mainly uses the query method 1 or query method 3 mentioned above to perform function query. Specifically, this part indicates that when it is analyzed that the task to be executed contains the function hive.function(arg1) (i.e., a target custom function in the embodiment of the present application), a query is performed in the function list registered by the UDF Wrapper (i.e., the registered function subset of the wrapper in the embodiment of the present application).

[0244] In the case of inquiries, Figure 3 The temporary custom function construction module shown will construct a temporary UDF according to the UDF protocol of the computing engine. The subsequent UDF Wrapper will perform data type conversion, function implementation class loading and function execution according to the temporary UDF, and the packaging and loading process of the complete function. For the specific implementation method, please refer to the following embodiment.

[0245] It should be noted that Figure 3 The logic diagram shown is just a simple example, and the execution order of each module and related steps is also just a simple example, which can be flexibly adjusted according to actual needs. For example, data type conversion can include input parameter type conversion and execution result type conversion, where the input parameter type conversion comes first, and the execution result type conversion needs to be implemented after the function is executed, and so on.

[0246] In the embodiment of the present application, through the close interaction between the UDF Wrapper and the computing engine, the user can conveniently use the custom function in the computing engine without modifying the internal structure and code of the computing engine. The specific process is as follows:

[0247] S23: If the target custom function is found, a temporary custom function corresponding to the target custom function is constructed according to the custom function protocol of the computing engine.

[0248] In the embodiment of the present application, considering that the function is dynamic, the input parameters of different functions may be different. Because a temporary UDF is constructed, the computing engine can handle different types of user-defined functions (UDFs) in a universal way, regardless of the number, type and return type of the input parameters. This dynamic processing method eliminates the need for the computing engine to implement separate processing logic for each specific UDF, but instead calls them uniformly through temporary UDFs, thereby enhancing the adaptability and extensibility of the computing engine to various UDFs. Specifically, the temporary UDF is equivalent to the UDF of the computing engine, and its main methods exist in the UDF Wrapper.

[0249] In an optional implementation, S23 may be implemented as follows to construct a temporary UDF, including the following steps S231 to S233 ( Figure 2 not shown):

[0250] S231: According to the custom function protocol of the computing engine, a temporary custom function with empty input parameters is constructed.

[0251] S232: Set the first input parameter of the temporary user-defined function to a string type, and write the function name of the target user-defined function in the form of a string.

[0252] S233: sequentially taking the input parameters of the target user-defined function as other input parameters after the function name, to obtain a temporary user-defined function corresponding to the target user-defined function.

[0253] In an embodiment of the present application, the process of constructing a temporary UDF corresponding to the target custom function according to the UDF protocol of the computing engine is intended to achieve indirect calling of the target custom function by creating a temporary custom function in a specific form to adapt to the protocol requirements of the computing engine.

[0254] The main method is to concatenate the function name and input parameters of the target custom function as the input parameters of the temporary custom function. Specifically, you first need to create a temporary UDF without input parameters according to the UDF protocol of the computing engine, that is, define a function structure, including the function name, return type (which may be void or a specific type) and an empty parameter list.

[0255] Furthermore, the first input parameter of the temporary user-defined function is set to a string type to store the function name of the target user-defined function. The purpose of this is to pass the identification information of the target user-defined function to the temporary UDF in the form of a parameter, so that the target user-defined function can be dynamically located and called according to the name at runtime.

[0256] Next, assign the name of the target user-defined function in string form to the string type parameter. In this way, when the temporary UDF is called, the caller UDF Wrapper can instruct the temporary UDF to call the corresponding actual target user-defined function by passing in the function name of the target user-defined function as a parameter.

[0257] After setting the first parameter of the temporary UDF (the function name of the target custom function), add all the remaining input parameters of the target custom function to the parameter list of the temporary custom function in sequence. The type, order, and number of these parameters should be exactly the same as those of the target custom function to ensure that the temporary UDF can receive the same input data as the target custom function.

[0258] After adding parameters, the parameter list of the temporary user-defined function will completely simulate the parameter structure of the target user-defined function, so that the UDF Wrapper can pass data to the temporary UDF in the same way as directly calling the target user-defined function.

[0259] For example, the target user-defined function in the user SQL is function(arg1), where function is the function name of the target user-defined function and arg1 is the input parameter of the target user-defined function. The corresponding temporary user-defined function can be expressed as wrapper(function,arg1), where wrapper is the function name of the temporary user-defined function, function is the first input parameter of the temporary user-defined function, and arg1 is the second input parameter of the temporary user-defined function, which is also the input parameter of the target user-defined function function(arg1).

[0260] For another example, the target user-defined function in the user SQL is function(arg1,arg2,arg3), where function is the function name of the target user-defined function, arg1, arg2, and arg3 are the first, second, and third input parameters of the target user-defined function, respectively. The corresponding temporary user-defined function can be expressed as wrapper(function,arg1,arg2,arg3), where wrapper is the function name of the temporary user-defined function, function is the first input parameter of the temporary user-defined function, arg1, arg2, and arg3 are the second, third, and fourth input parameters of the temporary user-defined function, respectively, and are also the three input parameters of the target user-defined function function(arg1,arg2,arg3).

[0261] In the above implementation, the temporary custom function in the present application receives the function name of the target custom function through a parameter, thereby realizing a dynamic call to the target custom function. Different target custom functions can be flexibly switched to be called at runtime by simply changing the passed-in function name parameter without modifying the code or recompiling. This dynamism is conducive to responding to changes in business needs or function version updates.

[0262] In addition, this application ensures compatibility with the computing engine by constructing a temporary custom function that complies with the computing engine UDF protocol. Even if the implementation details of the target custom function are not completely consistent with the requirements of the computing engine, the temporary custom function can be used as an intermediary to ensure that the calling process complies with the protocol specification and avoid runtime errors. Regardless of the specific implementation of the target custom function, the caller always calls through the unified interface of the temporary custom function. This simplifies the calling code, avoids a large number of code modifications caused by changes in the target custom function, and improves the stability and maintainability of the code.

[0263] The following describes the process of wrapping and loading temporary custom functions using UDF Wrapper:

[0264] S24: After loading the corresponding function implementation class according to the input parameters of the temporary custom function through the custom function wrapper, the temporary custom function is executed through the evaluation method of the function implementation class to obtain the execution result corresponding to the target custom function.

[0265] In the embodiment of the present application, a custom function wrapper UDF Wrapper is introduced as a unified interface, and the user's existing Hive UDF only needs to be wrapped and then loaded into different computing engines through the UDF protocols of different computing engines.

[0266] Specifically, when a function is dynamically packaged and loaded into the computing engine through UDF Wrapper, UDF Wrapper, as a unified interface, provides a bridge between the computing engine and the UDF implementation. It is responsible for managing the logic of UDF registration, loading, parameter parsing, and calling, so that the computing engine can call different types of UDFs in a unified way.

[0267] When the temporary custom function needs to be executed, the UDF Wrapper queries and loads the corresponding function implementation class from the registered UDF list based on the information provided by the temporary custom function (especially the function name). The function implementation class usually contains a core execution logic method. For example, in Hive or Spark UDF, this method is often called evaluate. The UDF Wrapper uses reflection or other mechanisms to call the evaluate method and pass in the parameters of the temporary custom function. After the evaluate method is executed, one or more result values ​​are returned, which constitute the execution result of the target custom function. These output results are then integrated back into the query result set and become part of the data ultimately returned to the user.

[0268] Specifically, the UDF Wrapper in the embodiment of the present application maintains a list of registered UDFs, which needs to be pre-built. For example, in this article, it can be built after the UDF Wrapper related functions are enabled, or it can be built after the target custom function is queried, or it can be built before the target custom function is queried, so that when querying in the registered function subset of the wrapper, the list can be directly used for querying, etc. The list contains all known UDFs that can be called by the computing engine. The mapping relationship between the UDF in the registered UDF list and the corresponding function implementation class can be stored in advance through a preset dictionary. An optional construction method is as follows:

[0269] By statically registering, write the function implementation class of the custom function (such as Hive UDF) registered by the object (such as the user) into the preset dictionary. The key in the preset dictionary is the function name, and the value is the function implementation class. In this way, you can subsequently perform function queries inside the custom function wrapper based on the preset dictionary to query the custom function and its corresponding function implementation class according to the function name.

[0270] In the embodiment of the present application, the preset dictionary can be in the form of a Map. For example, by static registration, the user's existing Hive UDF implementation is written into a Map, where the key is the name of the function and the value is the implementation class of the UDF. The Map is mainly used for function query inside the UDF Wrapper. Later, the implementation class of the UDF can be obtained from it according to the function name, and then the function is executed according to the evaluate method in the function implementation class.

[0271] In addition to the Map method, it can also be stored through arrays or other structures. Specifically, the index in the array is the key, and the access speed is extremely fast.

[0272] As shown in the following Table 1, it is an example of a preset dictionary in an embodiment of the present application:

[0273] Table 1 Preset dictionary

[0274]

[0275] Table 1 above briefly lists several Hive UDFs and their possible implementation classes. The details are as follows:

[0276] (I) Custom string processing function:

[0277] UDF name: CustomStringTrim;

[0278] Implementation class: com.example.udf.CustomStringTrimUDF;

[0279] Function description: This UDF provides more complex string trimming functions, such as trimming based on a specific character set rather than just spaces, or supporting the removal of multi-character prefixes and suffixes.

[0280] (ii) Date format conversion function:

[0281] UDF name: DateFormatConverter;

[0282] Implementation class: com.example.udf.DateFormatConverterUDF;

[0283] Function description: This UDF is used to convert the date or timestamp field in Hive from one format to another.

[0284] (III) Geographic distance calculation function:

[0285] UDF name: GeoDistanceCalculator;

[0286] Implementation class: com.example.udf.GeoDistanceCalculatorUDF;

[0287] Function description: This UDF receives two longitude and latitude coordinates as input, calculates and returns the geographic straight-line distance between the two, and is used for spatial data analysis.

[0288] (IV) Text sentiment analysis function:

[0289] UDF name: SentimentAnalyzer;

[0290] Implementation class: com.example.udf.SentimentAnalyzerUDF;

[0291] Function description: This UDF can encapsulate an external text analysis library to perform sentiment analysis (such as positive, negative, and neutral) on text data, providing additional dimensions of information for data mining and business intelligence.

[0292] It should be noted that the UDFs listed above and their corresponding implementation classes are just simple examples, and the above examples are only conceptual descriptions. The UDFs of actual projects depend on specific business requirements and the implementation of developers. In actual applications, the specific implementation class names and code details will vary according to the actual project coding standards and requirements, and this article does not make specific restrictions.

[0293] On the basis of the above implementation, a statically registered dictionary is used to store the user's existing custom function information, making function management more intuitive and convenient. In addition, function queries can be performed directly based on the preset dictionary and the function implementation class can be obtained, which greatly improves query efficiency.

[0294] When loading function wrappers, this application takes into account that the data types used in different computing engines may be different, and these data types may not be the same as the data types supported by UDF Wrapper, that is, these data types may not be fully compatible with the data types supported by Hive UDF. Therefore, type conversion is required during the function wrapper loading process to ensure the correct execution of the function.

[0295] In an optional implementation, before executing a temporary custom function through the evaluation method of the function implementation class, it is first necessary to perform input parameter type conversion to convert the input parameters of the temporary custom function from data types supported by the calculation engine to target data types.

[0296] Specifically, the target data type in this article refers to the data type supported by Hive UDF, which is a set of data types defined by Hive, including basic types (such as strings, integers, floating-point numbers, etc.) and complex types (such as structures, column vectors, etc.).

[0297] like Figure 7 As shown, it is a specific implementation logic diagram of function packaging and loading in an embodiment of the present application. After constructing a temporary custom function according to the computing engine UDF protocol, the function packaging and loading is performed through the UDF Wrapper. The process is mainly divided into three parts, among which the white box represents data execution and conversion, the gray box represents the class loading of the UDF, and the black box represents the function query. Specifically, these three parts can be divided into 6 small steps: input parameter type conversion (referred to as input parameter type conversion) -> input parameter verification -> function query -> thread level function implementation class loading -> function execution -> execution result type conversion (referred to as result type conversion).

[0298] In the function packaging and loading process in the embodiment of the present application, it is first necessary to convert the input parameters of the temporary custom function. Since the internal implementation of Hive UDF only accepts Hive data types as input parameters, if the data type of the computing engine is directly used as the input parameter, the function may not be executed correctly. In addition, because the function implementation class (UDF Class) of the custom function is not changed, the input parameters during execution can only be Hive data types, otherwise, the input parameter check of Hive UDF cannot be passed. Therefore, it is necessary to convert the input parameters of the temporary UDF from the data types supported by the computing engine to the Hive data types.

[0299] Then, the converted input parameters are checked to ensure that the input parameters conform to the data types supported by the target data source.

[0300] In the embodiment of the present application, Hive UDF will check whether the input parameters meet its expected data type when executing to ensure that all input parameters have been correctly converted to the data type required by the function. If the input parameter is not the data type of Hive, the execution of the function will fail. Therefore, when executing a user-defined Hive UDF, data type conversion is required to ensure the correct execution of the function, and the converted data type is checked by the input parameter to determine whether it meets the data type supported by the target data source.

[0301] Specifically, the target data source refers to Hive, that is, whether the input parameters are successfully converted to the Hive data type is verified. If yes, the subsequent process can be successfully executed. If not, the execution of the function will fail. At this time, a type mismatch error or exception can be thrown, such as UDFArgumentException, indicating that the parameter type in the function call does not meet the expectations, resulting in the failure of the function execution.

[0302] After the input parameter verification is successful, the function query process is re-executed to query the temporary custom function (actually the corresponding target custom function) and its corresponding function implementation class. The specific function query method can refer to the function query method 1, function query method 2 or function query method 3 listed in the above embodiment, which will not be repeated here.

[0303] It should be noted that the function query in the above step S22 only queries whether the target custom function exists in the existing function set, and the function query in step S23 is to query the function for packaging and loading after determining that the target custom function exists in the existing function set.

[0304] This application takes into account that computing engines mostly use threads to run split tasks in order to improve execution efficiency. Figure 8 As shown, it is a multi-threaded execution logic diagram in an embodiment of the present application. Among them, SQL1 represents task 1 to be executed, SQL2 represents task 2 to be executed, and each task to be executed can be switched to n subtasks, such as SQL1 is divided into n subtasks 1, SQL2 is divided into n subtasks 2, and these subtasks can be run through threads c1, c2, c3, c4...

[0305] However, during the running process, due to the alternating running of various threads, frequent context switching occurs. At this time, if the above UDF Class is directly used for calculation, it is easy to cause UDF class loading problems.

[0306] In order to overcome the above problems, the present application adds a thread-level class loader to solve the problem. In an optional implementation, the function implementation class is loaded by the following thread-level context switching class loading logic:

[0307] First, before calling the evaluate method of the temporary UDF, determine whether the current thread can query the corresponding function implementation class based on the input parameters of the temporary custom function;

[0308] If it is determined that the current thread can query the corresponding function implementation class, then load the function implementation class directly;

[0309] If it is determined that the current thread cannot query the corresponding function implementation class, the relevant thread-level class loader is started to reload the function implementation class.

[0310] In a multi-threaded environment, each thread may need to load different classes, so this application proposes a thread-related class loader to ensure that each thread can correctly load and use the required classes. This class loader may be a function or a class, which is responsible for dynamically loading classes at runtime to meet the needs of threads. The specific implementation method may vary depending on the programming language and framework, and this article does not make specific restrictions, but in general, its goal is to ensure the correctness and efficiency of class loading in a multi-threaded environment.

[0311] Here is a detailed description of this thread-level context switch class loading logic:

[0312] First, before calling the evaluate method of the temporary UDF, try to determine whether the current thread can find the Class of the corresponding function based on the input parameters of the temporary custom function (especially the string parameter containing the function name).

[0313] If the current thread can find the class of the corresponding function, it can proceed directly to the next step. Otherwise, further measures need to be taken to load the function implementation class of the temporary custom function. For example: the current thread is Figure 8 In the c2 thread, when executing the SQL1 subtask, the c2 thread loaded a class. When executing the SQL2 subtask this time, this class still needs to be loaded. This means that the class has been loaded by other operations in this thread before. The current thread can find the Class of the corresponding function and can proceed directly to the next step.

[0314] If the current thread fails to find the class of the corresponding function, it may be because the class has not been loaded into the current thread context. At this time, start the relevant thread-level class loader (such as a custom class loader created specifically for the thread) and retry to load the function implementation class of the temporary custom function.

[0315] In the embodiment of the present application, the thread-level class loader may have a specific class search path, class loading strategy or cache mechanism, which is helpful to load specific class resources in a specific thread environment. By starting such a loader, it can be ensured that the implementation class of the target function is correctly loaded in the current thread.

[0316] In the above implementation, the above class loader can solve the problem of being unable to find the user UDF Class due to frequent online context switching during multi-threaded execution. In addition, starting the thread-level class loader to reload the function implementation class implements thread isolation of class loading, which helps to avoid class loading conflicts in a multi-threaded environment and ensures that each thread can independently and accurately load the required class resources. At the same time, the classes loaded by the thread-level class loader are usually only visible to the current thread and will not affect other threads, reducing the complexity of the global class space, ensuring that the function implementation class in a multi-threaded and complex class loading environment is correctly, efficiently and flexibly loaded, and improving the stability and maintainability of the system.

[0317] After loading the function implementation class, you can execute the class through the UDF Wrapper. The class mainly contains an evaluate method, which is used to execute the UDF. This method is the core of the UDF and contains custom logic processing. It receives input parameters, performs necessary calculations or processing, and returns the results. It should be noted that the signature of the evaluate method should match the input parameter type and return type declared by the UDF.

[0318] It should be noted that this application also takes into account that Hive currently has two types of UDFs: the default GenericUDF and the traditional UDF. Among them, GenericUDF is a general UDF form of Hive, which is suitable for most situations, while the traditional UDF is another form of UDF in Hive, which may have specific execution logic. The above two UDFs differ in implementation methods, interface definitions, and execution logic, which causes compatibility issues in the unified execution layer, resulting in the need for separate processing in the unified execution layer, increasing code complexity and maintenance difficulty. Therefore, this application proposes a unified execution logic, which effectively solves compatibility issues by performing unified function execution when executing user-defined Hive UDFs. An optional implementation method is as follows:

[0319] Before executing a temporary custom function through the evaluate method of the function implementation class, determine the function type of the temporary custom function. This step specifically refers to analyzing whether the temporary custom function is one of the two types of UDFs currently supported by Hive, the default GenericUDF or the traditional UDF. These two different types correspond to different execution logics. Among them, the execution logic of the traditional UDF is that when executing, Hive will call the corresponding method according to the specific type of the incoming data. This design is relatively direct, but it is not flexible enough for type processing and is not convenient for processing complex data types or dynamic types. For GenericUDF, since this type is type-independent when processing data, it dynamically checks and converts data types through ObjectInspector, so it is more flexible and can better adapt to different types of data processing requirements, reducing code duplication and improving code maintainability and extensibility.

[0320] To solve the above compatibility issues and to ensure that all user-defined Hive UDFs can be correctly executed, this application proposes to convert all types of user-defined Hive UDFs (including traditional UDFs) into a pre-defined unified type.

[0321] That is, if the temporary custom function corresponds to the target execution logic target function type (ie, belongs to the traditional UDF), the temporary custom function is converted into a predefined unified type to execute the temporary custom function using the unified function execution logic.

[0322] In the embodiments of the present application, considering that GenericUDF is more flexible than traditional UDF, the present application uses GenericUDFBridge as a predefined unified type, which is a special class that inherits from GenericUDF and provides a mechanism that can bridge the original UDF and GenericUDF interfaces, so that the functions that were originally UDFs can be processed and executed in the form of GenericUDF.

[0323] In this way, by converting the traditional UDF into GenericUDFBridge (inherited from GenericUDF), all Hive UDF classes can be uniformly converted into GenericUDF. During subsequent execution, an evaluate method can be called to run the function, which can solve the compatibility problem of the execution layer and implement unified function execution.

[0324] In the above implementation, after the function execution is uniformly converted to GenericUDFBridge, the execution layer faces a single type of GenericUDF, and there is no need to deal with the differences between different UDF types, which simplifies the execution logic, reduces code complexity, improves code readability and maintainability, and solves the compatibility problem of the execution layer with different UDF types. Whether it is a UDF that directly implements GenericUDF or the original UDF, it can now be processed and executed in a unified manner, enhancing the compatibility and stability of the system.

[0325] In addition, the traditional UDF may be used as a unified type, or a predefined third type other than GenericUDF and the traditional UDF (other types than the above GenericUDFBridge) may be used as a unified type, which is not specifically limited in this document.

[0326] In addition, when Hive introduces more types of UDFs or users customize other types of UDFs in the future, they can be easily incorporated into the unified execution system through a bridging mechanism similar to GenericUDFBridge, without the need for large-scale transformation of the execution layer, thus enhancing the scalability of the system. All UDFs are uniformly executed using the evaluate method of GenericUDF, providing a consistent interface for upper-level applications and developers, reducing the difficulty of use and debugging and improving development efficiency. The unified function execution method is conducive to resource optimization, such as function caching and execution plan reuse, because all UDFs follow the same execution model, which can allocate and schedule computing resources more efficiently.

[0327] In the embodiment of the present application, after executing the function through the evaluate method, one or more values ​​will be returned, namely the execution results in this article. The types of these values ​​should be consistent with the return type declared by the UDF, such as the data type of Hive. Therefore, after obtaining the execution result corresponding to the target custom function, it is also necessary to perform the execution result type conversion, converting the execution result from the target data type to the data type supported by the computing engine.

[0328] Because the calculated results will be used in the next calculation task in the engine, and most computing engines' UDF frameworks have default data types that are not compatible with Hive data types. Therefore, after obtaining the execution results, you need to convert the execution results from Hive data types to computing engine data types to ensure that the results can be used correctly by the computing engine.

[0329] like Fig. 9 As shown, it is a schematic diagram of a type conversion in an embodiment of the present application. Specifically, Fig. 9Examples of input parameter type conversion and execution result type conversion related to three computing engines are listed. Among them, the triangle represents type A, the hexagon represents type B, the circle represents type C, and the diamond represents Hive type. Assume that the data type supported by computing engine 1 is type A, the data type supported by computing engine 2 is type B, and the data type supported by computing engine 3 is type C. For the input parameters, they must first be uniformly converted to Hive types.

[0330] Then, by executing the function, the execution result of Hive type is obtained, and finally converted into the data type supported by the corresponding computing engine. For example, for computing engine 1, the execution result is converted into type A, for computing engine 2, the execution result is converted into type B, and for computing engine 3, the execution result is converted into type C. This conversion process is from Hive data type to computing engine data type to meet the internal data type requirements of the computing engine. This conversion process ensures that the results of user-defined Hive UDF can be used correctly by the computing engine, so as to participate in subsequent computing tasks.

[0331] In the above implementation, the temporary UDF uses the function name as an input parameter and performs type conversion and function call through the UDF Wrapper, ensuring type safety. The computing engine does not need to worry about compatibility issues between parameters of different types, because these conversions are automatically completed by the UDF Wrapper. In addition, the result type conversion also ensures that the return value can be correctly passed to the caller.

[0332] In addition, if type mismatch, illegal parameters, calculation errors, etc. are encountered during execution, the evaluate method or UDF Wrapper may throw an exception. In this way, the subsequent calculation engine will capture these exceptions and handle the errors according to the configuration or strategy, such as logging, terminating the query, or returning error information to the user.

[0333] After the UDF is executed, the computing engine can also perform some resource cleanup operations, such as releasing the resources allocated to the UDF instance, to maintain effective management and recycling of system resources.

[0334] In summary, this application has good versatility in most big data computing engines. It only needs to package the user's existing HiveUDF to make it into a UDF Wrapper, and then load the UDF Wrapper into different computing engines through the UDF protocols of different computing engines. In addition, the data types of different computing engines are converted in this process. This can achieve the effect of using functions with the same name and behavior for calculations between different computing engines. This allows developers to use the same function name and functional logic on different computing platforms (such as Spark, Flink, Presto, etc.), greatly improving the reusability of the code and reducing repeated development work due to platform differences.

[0335] Based on the same inventive concept, the embodiment of the present application also provides a function packaging loading device. Fig.10 As shown, it is a schematic diagram of the structure of the function packaging loading device 1000, which may include:

[0336] The parsing and analyzing unit 1001 is used to parse and analyze the task to be executed after receiving the task to be executed triggered by the object;

[0337] A query unit 1002 is used to determine whether the task to be executed includes a target user-defined function, and then query whether the target user-defined function exists in the existing function set;

[0338] The construction unit 1003 is used to construct a temporary custom function corresponding to the target custom function according to the custom function protocol of the computing engine if the target custom function is found;

[0339] The packaging loading unit 1004 is used to load the corresponding function implementation class according to the input parameters of the temporary custom function through the custom function wrapper, execute the temporary custom function through the evaluation method of the function implementation class, and obtain the execution result corresponding to the target custom function.

[0340] Optionally, the construction unit 1003 is specifically used for:

[0341] According to the custom function protocol of the computing engine, construct a temporary custom function with empty input parameters;

[0342] Set the first input parameter of the temporary custom function to string type and write the function name of the target custom function in string form;

[0343] The input parameters of the target user-defined function are sequentially used as other input parameters after the function name to obtain a temporary user-defined function corresponding to the target user-defined function.

[0344] Optionally, the packaging loading unit 1004 is further used for:

[0345] Before executing the temporary custom function through the evaluation method of the function implementation class, the input parameters of the temporary custom function are converted from the data types supported by the calculation engine to the target data types;

[0346] Verify the converted input parameters to ensure that the input parameters conform to the data types supported by the target data source;

[0347] After obtaining the execution result corresponding to the target custom function, the execution result is converted from the target data type to a data type supported by the computing engine.

[0348] Optionally, the packaging loading unit 1004 is specifically used for:

[0349] According to the input parameters of the temporary custom function, determine whether the current thread can query the corresponding function implementation class;

[0350] If it is determined that the current thread can query the corresponding function implementation class, then load the function implementation class directly;

[0351] If it is determined that the current thread cannot query the corresponding function implementation class, the relevant thread-level class loader is started to reload the function implementation class.

[0352] Optionally, the packaging loading unit 1004 is further used for:

[0353] Before executing the temporary user-defined function through the evaluation method of the function implementation class, the function type of the temporary user-defined function is determined;

[0354] If the temporary user-defined function corresponds to the target function type, the temporary user-defined function is converted into a predefined unified type so as to execute the temporary user-defined function using a unified function execution logic.

[0355] Optionally, the existing function set includes an engine built-in function subset, an engine custom function subset and a wrapper registered function subset; then the query unit 1002 is specifically used for:

[0356] If the function namespace specified for the target custom function is used, the function namespace is used as a prefix, and the function name and input parameters of the target custom function are concatenated. Then, the registered function subset of the wrapper is queried to see whether the target custom function exists.

[0357] If the function namespace is not used, the target user-defined function is queried in the existing function set based on the function name and input parameters of the target user-defined function.

[0358] Optionally, the query unit 1002 is specifically configured to:

[0359] If you specify to search in the registered function subset of the wrapper first, then based on the function name and input parameters of the target user-defined function, search in the registered function subset of the wrapper to see whether the target user-defined function exists;

[0360] If it is not specified to prioritize searching in the registered function subsets of the wrapper, the function subsets included in the existing function set are searched in the specified priority order according to the function name and input parameters of the target custom function.

[0361] Optionally, the query unit 1002 is specifically configured to:

[0362] If the target custom function exists in the engine built-in function subset, it is determined that the target custom function is found; if not, the query continues in the engine custom function subset;

[0363] If the target custom function exists in the engine custom function subset, it is determined that the target custom function is found; if not, the query continues in the wrapper registered function subset;

[0364] If the target user-defined function exists in the registered function subset of the wrapper, it is determined that the target user-defined function is queried; if not, it is determined that the target user-defined function is not queried.

[0365] Optionally, the query unit 1002 is specifically configured to:

[0366] If the target user-defined function exists in the registered function subset of the wrapper, it is determined that the target user-defined function is queried;

[0367] If it does not exist, the query is no longer performed in the engine's built-in function subset or the engine's custom function subset to determine that the target custom function is not found.

[0368] Optionally, the device further comprises:

[0369] The registration unit 1005 is used to write the function implementation class of the registered custom function of the object into a preset dictionary through static registration; wherein the key in the preset dictionary is the function name, and the value is the function implementation class. The preset dictionary is used for function query inside the custom function wrapper to query the function implementation class of the custom function according to the function name.

[0370] Optionally, the device further comprises:

[0371] The configuration unit 1006 is used to pre-start the relevant functions of the custom function wrapper in the computing engine.

[0372] Because the computing engine in this application does not directly load the target custom function contained in the task to be executed after receiving the task to be executed triggered by the object, but queries the function in the existing function set, and after determining that the function can be called normally, constructs a temporary custom function that complies with the computing engine UDF protocol to ensure compatibility with the computing engine. On this basis, a temporary custom function is used as an intermediary, and the target custom function is loaded through a custom function wrapper as a unified interface package. This method only needs to wrap the user's existing Hive UDF, and then through the UDF protocol of different computing engines, the original UDF function of the object can be guaranteed to be loaded into different computing engines. In the business migration scenario, this method loads the custom function that the object has been accustomed to using into the new computing engine without intrusively modifying the engine code, so as to achieve the purpose of non-sense migration of the business and improve the stability of the business in the process of switching computing engines.

[0373] In summary, the present application can solve the function compatibility problem between heterogeneous computing engines, shield the function differences between different computing engines, and enable tasks to be executed with the same function name to run on different computing engines, thereby meeting the computing needs of different business scenarios, reducing the complexity of task switching between different computing engines, and ensuring stability during changes in business computing needs.

[0374] For the convenience of description, the above parts are divided into modules (or units) according to their functions and described separately. Of course, when implementing this application, the functions of each module (or unit) can be implemented in the same or multiple software or hardware.

[0375] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.

[0376] After introducing the function package loading method and device according to the exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.

[0377] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.

[0378] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. In one embodiment, the electronic device may be a server, such as Figure 1 In this embodiment, the structure of the electronic device can be as follows: Fig.11 As shown, it includes a memory 1101 , a communication module 1103 and one or more processors 1102 .

[0379] The memory 1101 is used to store computer programs executed by the processor 1102. The memory 1101 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.

[0380] The memory 1101 may be a volatile memory, such as a random-access memory (RAM); the memory 1101 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 1101 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1101 may be a combination of the above memories.

[0381] The processor 1102 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 1102 is configured to implement the above function packaging loading method when calling a computer program stored in the memory 1101 .

[0382] The communication module 1103 is used to communicate with terminal devices and other servers.

[0383] The specific connection medium between the memory 1101, the communication module 1103 and the processor 1102 is not limited in the embodiment of the present application. Fig.11 In the embodiment, the memory 1101 and the processor 1102 are connected via a bus 1104. The bus 1104 is connected to the processor 1102 via a bus 1104. Fig.11 The connections between the other components are described with bold lines, which are only for illustration and are not intended to be limiting. The bus 1104 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Fig.11 The diagram shows that only one thick line is used, but this does not mean that there is only one bus or one type of bus.

[0384] The memory 1101 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the function packaging loading method of the embodiment of the present application. The processor 1102 is used to execute the above-mentioned function packaging loading method, such as Figure 2 shown.

[0385] In another embodiment, the electronic device may also be other electronic devices, such as Figure 1 The terminal device 110 shown in FIG. 1 is a terminal device 110 shown in FIG. 1 . In this embodiment, the structure of the electronic device can be as follows: Fig.12 As shown, it includes: a communication component 1210, a memory 1220, a display unit 1230, a camera 1240, a sensor 1250, an audio circuit 1260, a Bluetooth module 1270, a processor 1280 and other components.

[0386] The communication component 1210 is used to communicate with the server. In some embodiments, a wireless fidelity (WiFi) module may be included. The WiFi module belongs to a short-range wireless transmission technology. The electronic device can help the user to send and receive information through the WiFi module.

[0387] The memory 1220 can be used to store software programs and data. The processor 1280 executes various functions and data processing of the terminal device 110 by running the software programs or data stored in the memory 1220. The memory 1220 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. The memory 1220 stores an operating system that enables the terminal device 110 to run. In the present application, the memory 1220 can store an operating system and various application programs, and can also store a computer program that executes the function packaging loading method of the embodiment of the present application.

[0388] The display unit 1230 may also be used to display information input by the user or information provided to the user and a graphical user interface (GUI) of various menus of the terminal device 110. Specifically, the display unit 1230 may include a display screen 1232 disposed on the front of the terminal device 110. The display screen 1232 may be configured in the form of a liquid crystal display, a light emitting diode, etc. The display unit 1230 may be used to display the user interface of the relevant client in the embodiment of the present application, such as a query interface, etc.

[0389] The display unit 1230 can also be used to receive input digital or character information and generate signal input related to user settings and function control of the terminal device 110. Specifically, the display unit 1230 may include a touch screen 1231 arranged on the front of the terminal device 110, which can collect user touch operations on or near it, such as clicking a button, dragging a scroll box, etc.

[0390] The touch screen 1231 can be covered on the display screen 1232, or the touch screen 1231 and the display screen 1232 can be integrated to realize the input and output functions of the terminal device 110. The integrated touch screen can be referred to as a touch display screen. In this application, the display unit 1230 can display the application and the corresponding operation steps.

[0391] The camera 1240 can be used to capture still images, and the user can publish the images taken by the camera 1240 through the application. The camera 1240 can be one or more. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the processor 1280 to convert it into a digital image signal.

[0392] The terminal device may further include at least one sensor 1250, such as an acceleration sensor 1251, a distance sensor 1252, a fingerprint sensor 1253, and a temperature sensor 1254. The terminal device may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, an infrared sensor, a light sensor, and a motion sensor.

[0393] The audio circuit 1260, the speaker 1261, and the microphone 1262 can provide an audio interface between the user and the terminal device 110. The audio circuit 1260 can transmit the electrical signal converted from the received audio data to the speaker 1261, which is converted into a sound signal for output. The terminal device 110 can also be equipped with a volume button for adjusting the volume of the sound signal. On the other hand, the microphone 1262 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1260 and converted into audio data, and then the audio data is output to the communication component 1210 to be sent to, for example, another terminal device 110, or the audio data is output to the memory 1220 for further processing.

[0394] The Bluetooth module 1270 is used to exchange information with other Bluetooth devices having Bluetooth modules through the Bluetooth protocol. For example, the terminal device can establish a Bluetooth connection with a wearable electronic device (such as a smart watch) that also has a Bluetooth module through the Bluetooth module 1270 to exchange data.

[0395] The processor 1280 is the control center of the terminal device. It uses various interfaces and lines to connect various parts of the entire terminal. It executes various functions of the terminal device and processes data by running or executing software programs stored in the memory 1220 and calling data stored in the memory 1220. In some embodiments, the processor 1280 may include one or more processing units; the processor 1280 may also integrate an application processor and a baseband processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the baseband processor mainly processes wireless communications. It is understandable that the above-mentioned baseband processor may not be integrated into the processor 1280. In the present application, the processor 1280 can run the operating system, application programs, user interface display and touch response, as well as the function package loading method of the embodiment of the present application. In addition, the processor 1280 is coupled to the display unit 1230.

[0396] In some possible implementations, various aspects of the function package loading method provided in the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the function package loading method according to various exemplary embodiments of the present application described above in this specification. For example, the electronic device may execute the following steps: Figure 2 Follow the steps shown in .

[0397] The program product may adopt any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination thereof. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.

[0398] The program product of the embodiment of the present application may adopt a portable compact disk read-only memory (CD-ROM) and include a computer program, and can be run on an electronic device. However, the program product of the present application is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which can be used by or in combination with a command execution system, apparatus, or device.

[0399] A readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, wherein a readable computer program is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the foregoing. A readable signal medium may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.

[0400] The computer program embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.

[0401] The computer program for performing the operation of the present application can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java, C++, etc., and also conventional procedural programming languages ​​such as "C" language or similar programming languages. The computer program can be executed entirely on the user electronic device, partially on the user electronic device, as an independent software package, partially on the user electronic device and partially on the remote electronic device, or completely on the remote electronic device or server. In the case of involving a remote electronic device, the remote electronic device can be connected to the user electronic device through any type of network including a local area network (LAN) or a wide area network (WAN), or can be connected to an external electronic device (e.g., using an Internet service provider to connect through the Internet).

[0402] It should be noted that, although several units or subunits of the device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more units described above can be embodied in one unit. Conversely, the features and functions of one unit described above can be further divided into multiple units to be embodied.

[0403] In addition, although the operations of the method of the present application are described in a specific order in the drawings, this does not require or imply that the operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps.

[0404] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain a computer-usable computer program.

[0405] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program commands. These computer program commands can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the commands executed by the processor of the computer or other programmable data processing device generate commands for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0406] These computer program commands may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the commands stored in the computer readable memory produce an article of manufacture comprising a command device, the command device implementing the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0407] These computer program commands can also be loaded onto a computer or other programmable data processing device so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the commands executed on the computer or other programmable device provide the instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0408] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.

[0409] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

Claims

1. A function packaging loading method, characterized in that: Applied to a computing engine, the method comprises: After receiving the pending tasks triggered by the object, the pending tasks are analyzed; Determining that the task to be executed includes a target user-defined function, querying whether the target user-defined function exists in the existing function set; If the target custom function is found, a temporary custom function with empty input parameters is constructed according to the custom function protocol of the computing engine; the first input parameter of the temporary custom function is set to a string type, and the function name of the target custom function is written in the form of a string; the input parameters of the target custom function are sequentially used as other input parameters after the function name to obtain a temporary custom function corresponding to the target custom function; After loading the corresponding function implementation class according to the input parameters of the temporary custom function through the custom function wrapper, the input parameters of the temporary custom function are converted from the data type supported by the computing engine to the target data type, and the function type of the temporary custom function is determined. If the temporary custom function corresponds to the target function type, the temporary custom function is converted to a predefined unified type; using a unified function execution logic, the temporary custom function is executed through the evaluation method of the function implementation class to obtain the execution result corresponding to the target custom function, and the execution result is converted from the target data type to the data type supported by the computing engine.

2. The method according to claim 1, characterized in that After converting the input parameter of the temporary custom function from a data type supported by the computing engine to a target data type, the method further includes: The converted input parameters are checked to determine whether the input parameters conform to the data types supported by the target data source.

3. The method according to claim 1, characterized in that The step of loading the corresponding function implementation class according to the input parameters of the temporary custom function includes: Determine whether the current thread can query the corresponding function implementation class according to the input parameters of the temporary custom function; If it is determined that the current thread can query the corresponding function implementation class, then directly load the function implementation class; If it is determined that the current thread cannot query the corresponding function implementation class, the relevant thread-level class loader is started to reload the function implementation class.

4. The method according to claim 1, characterized in that The existing function set includes an engine built-in function subset, an engine custom function subset and a wrapper registered function subset; then querying whether the target custom function exists in the existing function set includes: If a function namespace specified for the target user-defined function is used, the function namespace is used as a prefix, the function name and input parameters of the target user-defined function are concatenated, and then a query is made as to whether the target user-defined function exists in the registered function subset of the wrapper; If the function namespace is not used, then according to the function name and input parameters of the target user-defined function, it is queried in the existing function set whether the target user-defined function exists.

5. The method according to claim 4, characterized in that The querying whether the target custom function exists in the existing function set according to the function name and input parameters of the target custom function includes: If it is specified to search in the registered function subset of the wrapper first, then according to the function name and input parameters of the target user-defined function, it is searched whether the target user-defined function exists in the registered function subset of the wrapper; If it is not specified to prioritize searching in the registered function subsets of the wrapper, then the function subsets included in the existing function set are searched in turn according to the function name and input parameters of the target custom function and in the specified priority order.

6. The method according to claim 5, characterized in that According to the specified function subset priority order, the function subsets included in the existing function set are searched in turn, including: If the target user-defined function exists in the engine built-in function subset, it is determined that the target user-defined function is found; if not, the search continues in the engine user-defined function subset; If the target custom function exists in the engine custom function subset, determine that the target custom function is found; if not, continue to search in the wrapper registered function subset; If the target user-defined function exists in the registered function subset of the wrapper, it is determined that the target user-defined function is found; if not, it is determined that the target user-defined function is not found.

7. The method according to claim 5, characterized in that The querying whether the target custom function exists in the registered function subset of the wrapper includes: If the target user-defined function exists in the registered function subset of the wrapper, determining that the target user-defined function is found; If it does not exist, no further search is performed in the engine built-in function subset or the engine custom function subset to determine that the target custom function is not found.

8. The method according to any one of claims 1 to 7, characterized in that The method further comprises: The function implementation class of the registered custom function of the object is written into the preset dictionary through static registration; wherein the key in the preset dictionary is the function name, and the value is the function implementation class. The preset dictionary is used for function query inside the custom function wrapper to query the function implementation class of the custom function according to the function name.

9. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: In the computing engine, related functions of the custom function wrapper are started in advance.

10. A function packaging loading device, characterized in that: include: A parsing and analyzing unit, configured to parse and analyze the tasks to be executed after receiving the tasks to be executed triggered by the objects; A query unit, used for determining whether the task to be executed includes a target user-defined function, and then querying whether the target user-defined function exists in the existing function set; A construction unit, configured to construct a temporary custom function with empty input parameters according to the custom function protocol of the computing engine if the target custom function is found; The first input parameter of the temporary user-defined function is set to a string type, and the function name of the target user-defined function is written in the form of a string; the input parameters of the target user-defined function are sequentially used as other input parameters after the function name to obtain a temporary user-defined function corresponding to the target user-defined function; The packaging loading unit is used to load the corresponding function implementation class according to the input parameters of the temporary custom function through the custom function wrapper, convert the input parameters of the temporary custom function from the data type supported by the computing engine to the target data type, and determine the function type of the temporary custom function. If the temporary custom function corresponds to the target function type, convert the temporary custom function to a predefined unified type; use a unified function execution logic to execute the temporary custom function through the evaluation method of the function implementation class, obtain the execution result corresponding to the target custom function, and convert the execution result from the target data type to the data type supported by the computing engine.

11. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 9.

12. A computer-readable storage medium, characterized in that: It includes a computer program, and when the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any method described in claims 1 to 9.

13. A computer program product, characterized in that The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of any one of the methods described in claims 1 to 9.

Citation Information

Patent Citations

  • Big data processing method and system

    CN111897525A

  • Multi-grammar processing method and device for computing platform and readable storage medium

    CN114116683A

  • Method and system for realizing user-defined function

    CN115964050A

  • Stream batch task processing method, device and equipment for different computing frameworks

    CN118012896A

  • SQL grammar conversion method and device, storage medium and electronic equipment

    CN118132597A