Database hardware acceleration method, electronic equipment and storage medium

By injecting preset instructions into the database target query function to obtain query parameter information, recode it and configure it into the preset accelerator for redirect link processing, hardware acceleration without modifying the database source code is achieved, and the problem of difficult development in the existing technology and the need to maintain separate databases for different versions is solved.

CN120030051AActive Publication Date: 2025-05-23INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202510494914.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-18
Publication Date
2025-05-23
Estimated Expiration
2045-04-18

AI Technical Summary

Technical Problem

In the prior art, the development of database integration hardware acceleration function is difficult and requires separate maintenance for different versions of databases.

Method used

By injecting preset instructions into the target query function of the database, obtaining query parameter information, reencode it and configure it into the preset accelerator, and performing redirect link processing to achieve hardware acceleration.

Benefits of technology

Hardware acceleration is achieved without modifying the database source code, which solves the problem of difficult development and the need to maintain separate databases for different versions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030051A_ABST
    Figure CN120030051A_ABST
Patent Text Reader

Abstract

The invention discloses a database hardware acceleration method, electronic equipment and a storage medium, and relates to the technical field of computers.Parameters, namely query parameter information, of a target function in a query process are obtained by injecting an instruction into the target query function in a database, and the query parameter information is sent to an accelerator; the accelerator carries out processing in the data query process according to the query parameters to obtain target data; through the target directional link obtained by redirecting the database and the accelerator, the target data meeting the target filtering condition is read from the accelerator, and the technical effect of hardware acceleration can be realized without modifying a database source code, so that the technical problems of high difficulty in developing a database integrated hardware acceleration function and high efficiency in related technologies can be solved. And the technical problem that the databases of different versions need to be independently maintained is solved, and the technical effect of hardware acceleration of the database can be achieved without modifying the source code of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a database hardware acceleration method, electronic device and storage medium. Background Art

[0002] With the rapid development of information technology, fields such as big data, cloud computing, and artificial intelligence have put forward higher requirements on the performance of databases. As the core of information processing, the performance of databases directly affects the operating efficiency of the entire application. However, traditional databases often have performance bottlenecks when processing massive data and high concurrent requests. In order to solve this problem, database hardware acceleration methods have emerged.

[0003] In the prior art, the database hardware acceleration method generally integrates the hardware acceleration function into the database, which usually requires modifying the database source code or using a plug-in mechanism to implement it, and then writing a specific version of code adapted thereto. Therefore, in the prior art, there is a problem that the development of the database integrated hardware acceleration function is difficult and different versions of the database need to be maintained separately. Summary of the invention

[0004] The present application provides a database hardware acceleration method, an electronic device and a storage medium, so as to at least solve the problem in the related art that the development of database integrated hardware acceleration function is difficult and different versions of databases need to be maintained separately.

[0005] The present application provides a database hardware acceleration method, which includes: In response to the data query instruction, inject a first preset instruction into a target query function of the database, and obtain query parameter information of the target query function based on the first preset instruction; After re-encoding the query parameter information, the query parameter information is configured in the preset accelerator, and a redirection link is processed between the database and the preset accelerator based on the address of the file to be queried in the query parameter information to obtain a target-oriented link, wherein the target-oriented link at least includes a link pointing to the preset accelerator and a target mapping table corresponding to the address of the file to be queried; Extract the to-be-queried file in the memory to the accelerator based on the target directional link, and filter the to-be-queried file in the accelerator according to the target filtering condition in the query parameter information to obtain the target data, and the to-be-queried file is determined in the memory through the target mapping table in the target directional link; The target data in the preset accelerator is extracted into the database through the target-oriented link.

[0006] The present application also provides a database hardware acceleration device, comprising: An injection unit, configured to inject a first preset instruction into a target query function of a database in response to a data query instruction; An acquisition unit, configured to acquire query parameter information of a target query function based on a first preset instruction; A configuration unit, used to configure the query parameter information into a preset accelerator after re-encoding the data; A directional unit, configured to perform redirection link processing between the database and the preset accelerator based on the address of the file to be queried in the query parameter information to obtain a target directional link, wherein the target directional link at least includes a link pointing to the preset accelerator and a target mapping table corresponding to the address of the file to be queried; A first extraction unit, configured to extract the to-be-queried file in the memory to the accelerator based on the target-oriented link; A filtering unit, used for filtering the to-be-queried file in the accelerator according to the target filtering condition in the query parameter information to obtain target data, wherein the to-be-queried file is determined in the memory through the target mapping table in the target directional link; The second extraction unit is used to extract the target data in the preset accelerator into the database through the target-oriented link.

[0007] The present application also provides an electronic device, comprising: a memory for storing a computer program; and a processor for implementing the steps of any of the above-mentioned database hardware acceleration methods when executing the computer program.

[0008] The present application also provides a computer-readable storage medium, in which a computer program is stored, wherein when the computer program is executed by a processor, the steps of any of the above-mentioned database hardware acceleration methods are implemented.

[0009] The present application also provides a computer program product, including a computer program, which implements the steps of any of the above-mentioned database hardware acceleration methods when executed by a processor.

[0010] Through the present application, a database hardware acceleration method, electronic device and storage medium are provided, which inject instructions into the target query function in the database to obtain the parameters of the target function in the query process, namely the query parameter information, and send the query parameter information to the accelerator, which processes the data in the data query process according to the query parameters to obtain the target data; through the target-oriented link obtained by redirecting between the database and the accelerator, the target data that meets the target filtering conditions is read from the accelerator, and the technical effect of hardware acceleration can be achieved without modifying the database source code. Therefore, the technical problems in the related technology that the development of the database integrated hardware acceleration function is difficult and different versions of the database need to be maintained separately can be solved, so that the technical effect of database hardware acceleration can be achieved without modifying the database source code. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 A schematic diagram of a database hardware acceleration method provided in an embodiment of the present application; Figure 2 An overall schematic diagram of a database hardware acceleration method provided in an embodiment of the present application; Figure 3 A schematic diagram of a query parameter information acquisition principle provided in an embodiment of the present application; Figure 4 An example diagram of redirection processing based on soft connection provided in an embodiment of the present application; Figure 5 An example diagram of redirection processing based on adding target extended attributes provided in an embodiment of the present application; Figure 6 An example diagram of redirection processing based on an intermediate layer provided in an embodiment of the present application; Figure 7 An example diagram of a preset accelerator provided in an embodiment of the present application; Figure 8 An example diagram of target data provided by an embodiment of the present application; Fig. 9 An example diagram of obtaining target data in a preset accelerator provided in an embodiment of the present application; Fig.10 A schematic diagram of the structure of a database hardware acceleration device provided in an embodiment of the present application; Fig.11 A schematic diagram of the structure of another database hardware acceleration device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0013] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0014] It should be noted that, in the description of this application, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. The terms "first", "second", etc. in this application are used to distinguish similar objects, and are not used to describe a specific order or sequence.

[0015] In order to enable those skilled in the art to better understand the present application, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0016] Figure 1 A flowchart of a database hardware acceleration method provided in an embodiment of the present application is provided, and the method is described in detail in conjunction with the execution flow of the database hardware acceleration method.

[0017] like Figure 1 As shown, the database hardware acceleration method includes: Step 101, in response to a data query instruction, inject a first preset instruction into a target query function of a database, and obtain query parameter information of the target query function based on the first preset instruction.

[0018] In an embodiment of the present application, a data query instruction is a query instruction input by a user who needs to perform a data query. After responding to this query instruction, a first preset instruction can be injected into the target query function of the database. The first preset instruction is a custom-selected instruction, for example: a Berkeley Packet Filter (Berkeley Packet Filter, BPF) instruction under the Extended Berkeley Packet Filter (Extended Berkeley Packet Filter, eBPF) technology, etc. Specifically, this application does not limit the type of the first preset instruction.

[0019] The database is a custom selected database, and the database types include but are not limited to: MySQL, Oracle, SQLServer, PostgreSQL, etc. Specifically, this application does not impose any restrictions on the type of database.

[0020] To facilitate understanding, the following database is described using PostgreSQL as an example.

[0021] The target query function is the core function of the database to perform data scanning (including at least: PostgreSQL's ExecSeqScan function, etc.). The target query function is responsible for performing file reading, row data parsing, filter condition calculation and column projection operations according to the semantics of the Structured Query Language (SQL) statement.

[0022] After the first preset instruction is injected into the target query function, the structure for obtaining the query parameter information of the target query function contained in the first preset instruction, such as the BPF map structure (BPF map is a structure in the eBPF program, which provides a mechanism for exchanging data between user space and eBPF program, or between multiple eBPF programs. BPF map is an efficient key-value pair storage that can store data persistently in kernel space until it is explicitly deleted), will obtain the query parameter information in real time.

[0023] Furthermore, when injecting the first preset instruction and obtaining query parameter information, this operation can be performed through a preset loader, such as a BPF loader, etc. In order to facilitate understanding of the implementation process of the present application, the first preset instruction is subsequently explained using the BPF instruction as an example, and the preset loader is explained using the BPF loader as an example.

[0024] Specifically, regarding the implementation process of the present application, the present application embodiment provides an overall schematic diagram of a database hardware acceleration method, such as Figure 2 As shown, the injection of the first preset instruction and the acquisition of the query parameter information can be expressed as follows: through the BPF loader 201, the BPF program 202 is compiled into a BPF instruction 205, which is injected into the target query function 204 of the database 203. The BPF instruction includes a BPF map structure 206 for acquiring the query parameter information 207. The BPF loader acquires the query parameter information 207 by monitoring the BPF map structure 206.

[0025] Step 102, after data re-encoding the query parameter information, configure it into the preset accelerator, and perform redirection link processing between the database and the preset accelerator based on the address of the file to be queried in the query parameter information to obtain a target-oriented link, wherein the target-oriented link at least includes a link pointing to the preset accelerator and a target mapping table corresponding to the address of the file to be queried.

[0026] In the embodiments of the present application, data recoding refers to converting a specific data structure in the database (such as the tree expression of qual and the column format description of tupdesc) into a flattened instruction sequence that can be loaded by the preset accelerator. For example, encoding the operator hierarchy relationship in the filter condition as a bit mask and an operation code combination, encoding the storage format of the column field as a type identifier and an offset array, etc.

[0027] The preset accelerator is a user-selected accelerator, such as a Field-Programmable Gate Array (FPGA) hardware accelerator, etc. Specifically, this application does not impose any restrictions on the preset accelerator.

[0028] Accelerator configuration refers to writing the re-encoded query parameter information into the preset accelerator through the preset operating system kernel. Redirection link processing modifies the database's access path to the file to point to the accelerator's virtual device node. Specific implementation methods include but are not limited to: Soft link replacement: rename the file to be queried to a temporary file to be queried, and create a symbolic link pointing to the accelerator at the address of the file to be queried. When the database process accesses through the address of the file to be queried, it actually reads the data in the accelerator.

[0029] Extended attribute mapping: Add extended attributes to the file to be queried and record the node file pointing to the accelerator. In the file opening operation, the file to be queried and the node file of the accelerator are opened at the same time by intercepting the system call, and the node file handle of the accelerator is associated with the private data area of ​​the file handle to be queried, so as to realize the senseless redirection of read and write operations.

[0030] Targeted linking consists of two core elements: Link to accelerator: used to route database file read requests to the accelerator; Target mapping table: records the mapping relationship between the logical blocks and physical blocks of the file to be queried in the memory, so that the accelerator can directly access the file to be queried in the memory according to the physical address.

[0031] Specifically, Figure 2 As shown, when configuring the query parameter information to the accelerator and performing the redirection link processing, it can be understood as follows: the BPF loader 201 configures the query parameter information 207 to the accelerator driver 209 of the preset accelerator through the preset operating system 208. The BPF loader 201 redirects the query file according to the query parameter information 207 and creates a redirection link 210, which points to the accelerator driver.

[0032] Among them, the preset operating system is a custom-selected system used to execute the database hardware acceleration method, such as: Linux system, etc. Specifically, this application does not limit the preset operating system.

[0033] Step 103, based on the target directional link, the file to be queried in the memory is extracted to the accelerator, and the file to be queried is filtered in the accelerator according to the target filtering condition in the query parameter information to obtain the target data. The file to be queried is determined in the memory through the target mapping table in the target directional link.

[0034] In an embodiment of the present application, the accelerator driver corresponding to the preset accelerator directly reads the page data of the file to be queried from the storage device (such as a solid state drive (SSD), disk) according to the physical block information in the target mapping table, and distributes it to the parallel computing pipeline of the preset accelerator. Each pipeline includes: a parsing module: extracts row data from the file to be queried according to the file storage format and generates row data tuples; a filtering module: performs logical judgment on each row of data according to the target filtering conditions, and only retains rows that meet the conditions; a projection module: extracts the specified columns from the filtered rows according to the projection rules, and generates a streamlined data set; a merging module: reassembles the processed data according to the file storage format to obtain the target data, and writes it into the circular buffer.

[0035] The target data is the data to be queried, such as Figure 2 As shown, regarding determining the data to be queried and filtering the queried files to obtain the target data, it can be understood that the preset accelerator 213 reads the file to be queried from the memory 212 through the memory driver 211, loads it into the preset accelerator for calculation, and obtains data that meets the conditions, namely the target data.

[0036] Step 104: extract the target data in the preset accelerator into the database through the target-oriented link.

[0037] In the embodiment of the present application, when the database accesses the preset accelerator through the redirection link, what is actually read is the target data in the circular buffer of the preset accelerator. Since the target data is fully compatible with the storage format of the file to be queried, the database can directly receive the processing result without modifying the parsing logic, and it is considered that all target data meets the target filtering condition, thereby skipping the original software calculation process.

[0038] Specifically, Figure 2 As shown, when extracting the target data in the preset accelerator into the database, it can be understood that: the database 203 obtains the target data from the accelerator driver 209 of the preset accelerator 213 through the redirection link.

[0039] The present application discloses a database hardware acceleration method, electronic device and storage medium. The method injects instructions into the target query function in the database to obtain the parameters of the target function in the query process, i.e., query parameter information. The query parameter information is sent to the accelerator, and the accelerator processes the data query process according to the query parameters to obtain the target data. The target-oriented link obtained by redirecting between the database and the accelerator is read from the accelerator to obtain the target data that meets the target filtering conditions, so as to achieve the technical effect of hardware acceleration without modifying the database source code. Therefore, the technical problem that the development of the database integrated hardware acceleration function is difficult and needs to be maintained separately for different versions of databases in the related technology can be solved, so as to achieve the technical effect of hardware acceleration of the database without modifying the database source code. The method also supports the dynamic addition of hardware acceleration functions (acceleration functions of preset accelerators) during the operation of the database, without restarting the program and performing tedious operations such as compilation, configuration and deployment.

[0040] In one implementable manner of the disclosed embodiment, the target query function is in the form of a statement of custom selection, for example: it is usually expressed in the form of an SQL statement. For ease of understanding, the subsequent target query function is explained using the SQL statement form as an example. At this time, the form of the target query function includes but is not limited to: select field name, from database table name, where target filtering condition, that is, through the select clause, select the column field to be extracted from the row data of the file to be queried; through the from clause, select the file to be queried; through the where clause, set the target filtering condition of the column field.

[0041] It should be noted that when the database executes the target query function to query data, it will perform but not limited to the following steps: (1) According to the name of the file to be queried specified in the from clause, find the storage path of the file to be queried in the memory, that is, the address of the file to be queried, and open the file to be queried. The address of the file to be queried is stored in the function entry parameter: the node of the file to be queried.

[0042] (2) According to the where clause, read row data one by one from the file to be queried, and parse the row data column fields according to the file storage format; filter the column fields according to the target filter condition. The file storage format is stored in the function entry parameter: tuple descriptor; the target filter condition is stored in the entry parameter: target filter condition. The filter calculation corresponds to the sub-function of the filter condition generation function. If the target filter condition is not empty, the sub-function is executed. After the calculation is completed, the row data that meets the target filter condition is returned.

[0043] (3) According to the select clause, extract the column fields, perform projection calculation on the row data that meets the target filtering conditions, and extract the target column fields. The index number required to extract the column fields is stored in the input parameter: projection information. The projection calculation corresponds to the sub-function of the projection rule generation function. After the calculation is completed, the target column fields are extracted from the row data that meets the target filtering conditions and reassembled into a new row data, namely the target data.

[0044] It should be noted that before executing the scan function (ExecSeqScan) in the target query function, the database will first execute the filter condition generation function (ExecInitQual function) to generate the target filter condition; and execute the projection rule generation function (ExecBuildProjectionInfo function) to generate the projection rule.

[0045] At this point, it can be seen that the target query function includes multiple functions, namely, a filter condition generation function, a projection rule generation function, and a scanning function. Therefore, when injecting the first preset instruction, a section of instruction will be injected into different functions in the target query function, that is, the first preset instruction also includes multiple instructions. Therefore, when injecting the first preset instruction into the target query function of the database, it can also be implemented in but not limited to the following ways: inserting a first entry code instruction and a first end code instruction into the filter condition generation function in the target query function, wherein the first entry code instruction is at least used to obtain the target filter condition, and the first end code instruction is used to set the return value of the filter condition generation function to a null value; inserting a second entry code instruction and a second end code instruction into the projection rule generation function in the target query function, wherein the second entry code instruction is at least used to obtain the projection rule in the query parameter information, and the second end code instruction is used to set the return value of the projection rule generation function to a null value; inserting a third entry code instruction into the scanning function in the target query function, wherein the third entry code instruction is at least used to obtain the file storage format and the address of the file to be queried in the query parameter information.

[0046] In the embodiments of the present application, the specific method of instruction injection can also be implemented in the following manner but is not limited to: inserting a first entry code instruction at the entry position of the filter condition generation function in the target query function, wherein the first entry code instruction is at least used to obtain the target filter condition, and the target query function at least includes a filter condition generation function, a projection rule generation function and a scanning function; inserting a first end code instruction at the end position of the filter condition generation function, wherein the first end code instruction is used to set the return value of the filter condition generation function to a null value; inserting a second entry code instruction at the entry position of the projection rule generation function, wherein the second entry code instruction At least used to obtain the projection rules in the query parameter information, the query parameter information at least includes the file address to be queried, the target filtering condition, the projection rule and the file storage format; at the end position of the projection rule generation function, insert a second end code instruction, wherein the second end code instruction is used to set the return value of the projection rule generation function to a null value; at the entry position of the scanning function, insert a third entry code instruction, wherein the third entry code instruction is at least used to obtain the file address to be queried and the file storage format, and the first preset instruction at least includes a first entry code instruction, a first end code instruction, a second entry code instruction, a second end code instruction and a third entry code instruction.

[0047] The first entry code instruction, the second entry code instruction, and the third entry code instruction are in the form of custom setting instructions, such as: uprobe injection instruction, etc. The first end code instruction and the second end code instruction are also in the form of custom setting instruction, such as: uretprobe injection instruction, etc.

[0048] At this time, regarding injecting the first preset instruction into the target query function, the following methods may also be used but are not limited to: at the entry position of the filter condition generation function, use the uprobe injection instruction to obtain the target filter condition. At the end position of the filter condition generation function, use the uretprobe injection instruction to set the return value to null. At the entry position of the projection rule generation function, use the uprobe injection instruction to obtain the projection rule. At the end position of the projection rule generation function, use the uretprobe injection instruction to set the return value to null. At the entry position of the scanning function, use the uprobe injection instruction to obtain the address of the file to be queried and the file storage format.

[0049] Specifically, the implementation process of the embodiment of the present application can also be described through the following examples: (1) At the entry point of the filter condition generation function (ExecInitQual function), an instruction is injected through the uprobe mount point of the BPF loader. The instruction can obtain the data structure in the filter condition generation function. For each node in the data structure, the comparison operation and logical operator in the filter condition generation function are obtained to obtain the target filter condition.

[0050] (2) At the end of the ExecInitQual function, the return value is set to null through the uretprobe mount point of the BPF loader. After setting the return value to null, the return value of the target filter condition in the entry parameter of the scan function (ExecSeqScan) will be null, and the scan function will not perform parsing and filtering calculations, which can ensure that the data is filtered only once.

[0051] (3) At the entry point of the projection rule generation function (ExecBuildProjectionInfo function), the uprobe mount point injection instruction of the BPF loader is used to obtain the projection rule in the query parameter information, and then obtain the index number of the column field in the file to be queried.

[0052] (4) At the end of the ExecBuildProjectionInfo function, set the return value to null through the uretprobe mount point of the BPF loader. After setting the return value to null, the return value of the projection rule in the entry parameter of the scan function (ExecSeqScan) is null, and the scan function will not perform the projection calculation, which ensures that only one projection calculation is performed on the data.

[0053] (5) The entry position of the scanning function (ExecSeqScan function) is injected through the uprobe mount point of the BPF loader. In the scanning function, the storage path of the file to be queried in the memory, that is, the file path to be queried, can be parsed; the length and type value of each column of the file to be queried can be parsed to obtain the file storage format.

[0054] For other types of databases, such as MySQL, Oracle, SQLServer, etc., only the function name changes and the data structure is adjusted accordingly. The above process can be used to achieve the same technical effect, that is, the database hardware acceleration method can be applied to various types of databases. Specifically, the embodiments of the present application are not limited.

[0055] Through eBPF probe technology, query parameter information can be obtained in real time at the function level granularity without parsing SQL statements or relying on internal database logs, ensuring the accuracy and real-time nature of data collection; by modifying the function return value rather than directly intervening in the code logic, the database can skip repeated calculations, maintain the integrity of the native execution process, and avoid compatibility issues caused by code modifications; the extraction of filtering and projection parameters is advanced to the early stage of function execution to gain a time window for subsequent accelerator configuration, ensuring that hardware resources are initialized before the query starts, and achieving seamless connection of computing tasks; regardless of how the database type (PostgreSQL, MySQL, Oracle, etc.) changes, you only need to adjust the target function name and data structure parsing method (for example, the filter condition generation function name of MySQL is different), and you can reuse the same set of instruction injection logic to greatly reduce the adaptation cost of different databases and different versions of the same database.

[0056] In one implementable manner of the disclosed embodiment, the process of obtaining query parameter information of a target query function may also be implemented in the following manner but is not limited to: obtaining a query process identifier corresponding to each query process executed by the target query function, and performing matching processing in preset target identification information according to multiple query process identifiers to determine multiple target process identifiers, wherein the target process identifier is a query process identifier corresponding to a target query process in the query process, the target query process is a query process to be accelerated, and the preset target identification information includes identification information corresponding to the target query process; obtaining first parameter information corresponding to each query process based on a first preset instruction, and classifying the first parameter information according to the target process identifier to obtain classified first parameter information corresponding to each of the multiple target query processes; when it is determined that any classified first parameter information satisfies the preset parameter condition, the classified first parameter information that satisfies the preset parameter condition is determined as the query parameter information.

[0057] In an embodiment of the present application, the database provides services for multiple users. When each user logs in and performs a data query, a query process is created with a unique process identifier (ID), namely, the query process identifier (PID). In the database query process, when the target query function injected with the first preset instruction is executed, the execution of the first preset instruction is triggered. For the same query process, the target query function is executed one by one, that is, the filter condition generation function, the projection rule generation function, and the scanning function are triggered in turn, and the scanning function is executed repeatedly.

[0058] Among them, the preset parameter conditions are custom set conditions, such as: whether all parameters are collected, etc. Specifically, regarding the preset parameter conditions, the embodiments of the present application do not limit them.

[0059] Specifically, when obtaining query parameter information, not all query parameter information of query processes needs to be obtained. Only the query parameter information of the query process that needs to be accelerated, that is, the target query process, needs to be obtained. Among them, the preset target identification information is custom setting information, which records the white list of process ID numbers that support hardware acceleration, that is, the identification of the target query process. At this time, by querying the process identification and the preset target identification information, the target process identification corresponding to the target query process that needs to be performed can be determined, and then the query parameter information can be obtained according to the target process identification.

[0060] Specifically, the implementation process of this application can also be implemented in the following way: obtain a whitelist of process ID numbers that support hardware acceleration, that is, preset target identification information. Each user will use a user name or user ID to log in to the database, and the database will create a corresponding query process and assign a process ID number, that is, a query process identifier (PID). A whitelist can be set to support the hardware acceleration function for query process identifiers created by users in a specified user group; Monitor the BPF map structure, and classify and summarize the obtained parameter information corresponding to the query process according to the target process ID. For example, the query parameter information collected by the BPF map is classified and summarized according to the target process ID using the key-value structure; Determine whether there is a target query process, collect all query parameters (that is, the preset parameter condition is to collect all parameters), if there is, obtain query parameter information according to the collected query parameters, if not, continue to obtain query parameters. All query parameters include: the address of the file to be queried, the target filtering condition, the projection rule, and the file storage format.

[0061] For ease of understanding, the present application embodiment provides a schematic diagram of obtaining query parameter information, such as Figure 3 As shown, it is assumed that there are three users (user 1, user 2, user 3) logging into the database. A process will be created for each user in the database to process the data query instructions input by each user. Each process has a unique process number query process identifier (PID). By injecting the first preset instruction into each process, the parameters of the target function in each process are collected by monitoring in the BPF loader. For the user corresponding to the query process identifier, the process with special permissions (VIP) is the target query process. After collecting all the parameters required for a query, the hardware accelerator is started. For example: Figure 3 In the example, the target process is identified as user 1001, and the classified first parameter information includes file path (address of the file to be queried), storage format (file storage format), filtering condition (target filtering condition) and projection rule, which means that all parameters required for a query are collected at this time.

[0062] The data query process executed in the target query process is parsed, filtered, and projected by the hardware, and the process only needs to read the redirected file, thereby achieving hardware acceleration for specific user groups.

[0063] By matching the query process identifier, the target query process that needs to be accelerated can be accurately selected, avoiding unnecessary acceleration operations on all query processes, and improving the utilization efficiency of hardware resources. The first parameter information is classified and processed, so that the parameter information of each target query process is clearer and more organized, which is convenient for subsequent processing and use. By judging whether the classified first parameter information meets the preset parameter conditions, the validity and integrity of the query parameter information used for hardware acceleration are ensured, and the success rate and efficiency of hardware acceleration processing are improved. The preset target identification information and preset parameter conditions can be adjusted according to different application scenarios and requirements, so that the system has good flexibility and scalability.

[0064] Furthermore, it should be noted that after the query parameter information is re-encoded, the configuration into the preset accelerator may also be performed in the following manners, but is not limited to: (1) The file storage format contains a continuous array. Each element in the array represents the attributes of a column field in the corresponding file to be queried, including: column field name, column field index number, column field type, length and other information. The column field length and column field type are extracted, encoded into a continuous array, and configured into the preset accelerator.

[0065] (2) The target filter condition is a data structure of a linked list + binary tree. The linked list represents the logical operation in the filter condition, and the binary tree represents the comparison operation. Each node on the linked list + binary tree is traversed sequentially, the calculation parameter information is extracted, encoded into the filter instruction, and configured into the preset accelerator.

[0066] (3) The projection rule is a linked list structure, which contains the column index number selected in the select clause, the number of the extracted column index, encoded as the column field extraction number, and configured in the preset accelerator.

[0067] (4) Different files to be queried have different storage format conventions. The storage format convention information is encoded into a number and configured into the preset accelerator.

[0068] In one implementable manner of the embodiment of the present disclosure, the redirect link processing can also be implemented in the following manner but is not limited to: determining the file to be queried in the memory according to the address of the file to be queried; creating a soft link pointing to the preset accelerator according to the file to be queried, and obtaining a target-oriented link; or, adding a target extended attribute to the file to be queried, and generating a file handle pointing to the preset accelerator according to the added file to be queried, and obtaining a target-oriented link, wherein the target extended attribute at least includes a node file pointing to the preset accelerator; or, adding an intermediate layer between the operation layer and the application layer of the preset operating system, and creating a target-oriented link through the intermediate layer, wherein the preset operating system is a system for executing the database hardware acceleration method.

[0069] Specifically, related to the above-mentioned embodiments, when creating a soft link pointing to a preset accelerator and obtaining a target-oriented link, the following methods may also be used but are not limited to: creating a soft link pointing to a preset accelerator based on the file to be queried; renaming the file to be queried to obtain a temporary file to be queried, and determining a target mapping table of the temporary file to be queried in the memory based on the address of the temporary file to be queried, wherein the target mapping table is used to determine the position of the temporary file to be queried in the memory, and the address of the temporary file to be queried is the same as the address of the file to be queried; performing link determination processing based on the target mapping table and the soft link to obtain a target-oriented link.

[0070] In the embodiments of the present application, the following methods may also be used but are not limited to represent: rename the database table file (file to be queried) to a temporary table file (temporary file to be queried). Create a soft link with the same name as the database table file (file to be queried), and the soft link points to the node file created by the accelerator driver of the preset accelerator. Obtain the logical block and physical block mapping table of the temporary file to be queried on the disk, that is, the target mapping table. Pass the target mapping table as a parameter to the preset accelerator.

[0071] For ease of understanding, the present application embodiment provides an example diagram of redirection processing based on soft connection, such as Figure 4 As shown, it is assumed that the address of the file to be queried is / database / table.bin, and the node file created by the accelerator driver of the preset accelerator is / dev / fpga_cu0. At this time, the process of redirecting the link includes but is not limited to: (1) Rename / database / table.bin to / tmp / table_for_fpga.bin. Execute the command in the default operating system: mv / database / table.bin / tmp / table_for_fpga.bin.

[0072] (2) Create a soft link with the same name, pointing to the node file created by the accelerator driver of the preset accelerator. Execute the command in Linux: ln -s / database / table.bin / dev / fpga_cu0.

[0073] (3) Obtain the mapping table between the logical blocks and physical blocks of the temporary table file. Execute the command filefrg-v / tmp / table_for_fpga.bin in the preset operating system to obtain it, or implement it through the fiemap function.

[0074] (4) The mapping table obtained in the above steps, i.e., the target mapping table, is passed as a parameter to the accelerator driver through the interface of the accelerator driver of the preset accelerator.

[0075] Process redirection link processing through soft linking can be achieved through command line without modifying any code, reducing the complexity of redirection link processing.

[0076] Furthermore, when generating a file handle pointing to a preset accelerator based on the added file to be queried and obtaining a target-oriented link, the following methods may also be used but are not limited to: performing target extended attribute addition processing on the file to be queried to obtain the added file to be queried; performing handle generation processing based on the added file to be queried to obtain a first file handle and a second file handle, wherein the second file handle is a file handle pointing to the preset accelerator, the first file handle is generated based on the file to be queried, and the second file handle is generated based on the node file in the target extended attribute; determining a target mapping table of the file to be queried in the memory based on the first file handle, wherein the target mapping table is used to determine the file to be queried in the memory, and the first file handle is a file handle pointing to the memory; performing link determination processing based on the second file handle and the target mapping table to obtain a target-oriented link.

[0077] In the embodiments of the present application, the following method may be used but is not limited to: add a target extension attribute to the file to be queried. For example, additional meta information may be set for the file to be queried in the form of key-value via a command line. The target extension attribute content is the node file created by the accelerator driver, that is, the node file pointing to the preset accelerator.

[0078] Open the added file to be queried, generate two file handles, the first file handle and the second file handle, and use the second file handle generated by the node file in the target extended attribute as the private data of the first file handle generated by the file to be queried. When reading the database, it is replaced by reading the second file handle. In the reading function of the accelerator, the mapping table of logical blocks and physical blocks, that is, the target mapping table, is obtained through the first file handle.

[0079] For ease of understanding, the present application embodiment provides an example diagram of redirection processing based on adding target extended attributes, such as Figure 5 As shown, it is assumed that the address of the file to be queried is / database / table.bin, and the node file created by the accelerator driver of the preset accelerator is / dev / fpga_cu0. At this time, the process of redirecting the link includes but is not limited to: (1) Set the target extended attribute of / database / table.bin to point to the node file created by the accelerator driver of the preset accelerator. Execute the command in the preset operating system: setfattr -n "user.target_path" -v " / dev / fpga_cu0" / database / table.bin (2) When the query process calls the open function of the preset operating system, the function parameter is the file path / database / table.bin. The set target extended attributes can be obtained through the file path; open the file / database / table.bin to obtain the file handle file_table (the first file handle); open the / dev / fpga_cu0 file in the target extended attributes to obtain the file file_fpga (the second file handle); mount file_fpga to the private member variable of file_table and return file_table.

[0080] (3) When the query process calls the read function of the preset operating system, the parameter of the read function is the file handle file_table of / database / table.bin. The file_fpga can be obtained through its private member variable. In the subsequent read operation, the file_fpga file handle is used to replace the file_table file handle to read the file data.

[0081] (4) In the preset accelerator’s read operation function, the file_table file handle is passed in as a parameter. Through the file_table file handle, the physical block location of / database / table.bin stored on the disk, i.e., the target mapping table, can be obtained, and then the file to be queried can be loaded from the disk into the accelerator.

[0082] By adding redirection processing based on target extended attributes, the file storage path in the existing file system can be preserved, avoiding the risk of file system abnormalities caused by unexpected power failures. When reading data, the file handle is redirected to the preset accelerator; when writing data, the original file handle is still used, supporting simultaneous reading and writing operations on the query file.

[0083] Furthermore, when creating a target-oriented link through an intermediate layer, the following methods may be used but are not limited to: adding processing to the process intermediate layer between the operation layer and the application layer of a preset operating system to obtain an intermediate layer, wherein the preset operating system is a system for executing a database hardware acceleration method; generating a database directory based on files in a memory, and mounting the database directory to the intermediate layer; in the intermediate layer, generating a mapping list corresponding to the files to be queried based on the files to be queried and the database directory, and determining a target mapping table based on the mapping list; in the intermediate layer, creating a third file handle pointing to a preset accelerator, and performing link determination processing based on the third file handle and the target mapping table to obtain a target-oriented link.

[0084] In the embodiments of the present application, the following methods may be used but are not limited to: an intermediate layer is added between the operation layer and the application layer of the preset operating system. The preset operating system may form an intermediate layer through a file system in userspace (FUSE) mechanism or a stacked file system, and the developer may customize the processing logic in the intermediate layer.

[0085] Mount the database directory to the middle-layer directory. In the middle layer, add the mapping list of the file to be queried, that is, the mapping list corresponding to the file to be queried, and create the third file handle of the preset accelerator. In the middle layer, when the database performs a read operation, the third file handle of the preset accelerator is read. In the read function of the preset accelerator, the mapping table of the logical block and the physical block, that is, the target mapping table, is obtained through the mapping list.

[0086] For ease of understanding, the present application embodiment provides an example diagram of redirection processing based on the intermediate layer, such as Figure 6 As shown, the process of redirecting the link includes but is not limited to: (1) Create an intermediate file system between the operating layer and the application layer. For example, use the FUSE framework of the default operating system to develop a user-mode file system.

[0087] (2) Mount the database directory to the middle-layer directory. Use the command line in the default operating system: mount -tfuse database database_media. User read and write operations are all performed in the middle-layer directory (database_media directory). At this time, all read and write operations first enter the middle layer, and then the middle layer is responsible for the actual read and write implementation.

[0088] (3) Scan all file paths in the database, pass the file path as a parameter to the middle layer, and open the third file handle of the preset accelerator in the middle layer.

[0089] (4) In the middle layer, when the user reads a file in the mapping list corresponding to the file to be queried, the node file created by the corresponding preset accelerator in the table is read.

[0090] When redirection processing is performed based on the middle layer, the middle layer code can exist in the form of a module or application process, without modifying the preset operating system kernel code. The middle layer can be uninstalled at any time without restarting the preset operating system.

[0091] In one possible implementation of the embodiment of the present disclosure, when extracting the file to be queried in the memory into the accelerator, it can also be implemented in but not limited to the following manner: performing file acquisition processing in the memory according to the target mapping table in the target-oriented link to obtain the file to be queried; extracting the file to be queried into the accelerator.

[0092] In an embodiment of the present application, the preset accelerator can directly obtain the storage information of the file to be queried in the memory according to the target mapping table, and the preset accelerator loads the content of the file to be queried into the memory of the preset accelerator according to the target mapping table.

[0093] Through the target mapping table, the system can accurately locate and obtain the file to be queried in the memory, avoiding data reading errors and improving the accuracy of data acquisition. Extracting the file to be queried into the preset accelerator and utilizing the parallel computing capability of the accelerator can significantly improve the efficiency of data processing, especially for large-scale data query and processing tasks.

[0094] In one implementable manner of the embodiment of the present disclosure, when filtering a file to be queried, it can also be implemented in but not limited to the following manner: according to the file storage format, the field positions of the column fields corresponding to the multiple row data of the file to be queried are parsed; based on the field position, according to the target filtering condition, the column fields that meet the target filtering condition in the column fields corresponding to the multiple row data are judged to obtain the target column field; according to the projection rule, the row data including the target column field are projected to obtain the projected row data; according to the file storage format, the projected row data are merged to obtain the target data; and the target data is stored in the circular buffer of the preset accelerator.

[0095] In an embodiment of the present application, after the preset accelerator obtains the file to be queried, the file to be queried will be distributed in blocks to the computing pipeline of the preset accelerator. Each pipeline will parse, filter, and project the data of the file to be queried in parallel, and finally output it to the merging module. According to the file storage format, the projection results (projection row data) that meet the target filtering conditions are assembled into target data. The target data is output to the circular buffer. When the pipeline setting stops working, the target data is output to the circular buffer.

[0096] Further, for ease of understanding, the present application embodiment provides an example diagram of a preset accelerator, such as Figure 7 As shown, the preset accelerator includes: multiple computing units, a circular buffer and a message notification unit, each computing unit includes multiple parallel computing pipelines, each pipeline includes a parsing module, a filtering module, a projection module, and a merging module. A parsing module, used for parsing the column fields corresponding to the multiple rows of data from the file to be queried according to the file storage format; A filtering module is used to determine, based on the field position and the target filtering condition, the column fields that meet the target filtering condition among the column fields corresponding to the multiple rows of data, and obtain the target column field; A projection module, used for performing projection processing on the row data including the target column field according to the projection rule to obtain projection row data; A merging module is used to merge the projection row data according to the file storage format to obtain the target data; A circular buffer, used for storing target data and transmitting data storage information to a message notification unit; The message notification unit is used to generate notification information according to the data storage information and transmit the notification information to the database.

[0097] Further, for ease of understanding, the present application embodiment provides an example diagram of target data, such as Figure 8 As shown, in the memory, 8KB is used as the database page size to store the row data of the file to be queried; the number of rows in the page is stored at a fixed position on the page, and the metadata of the row data of the file to be queried is stored downward from the fixed position on the page, and the row data metadata includes the row length and the offset of the row data in the page; the row data is stored from the bottom of the page upward; each row data contains several column fields.

[0098] Further, for ease of understanding, the present application embodiment provides an example diagram of obtaining target data in a preset accelerator, such as Fig. 9 As shown, after parsing, filtering, and projecting each row of the file to be queried, the projection results of the row data that meet the filtering conditions are re-merged into one data, namely the target data, according to the data file storage format. The target data is submitted to the circular buffer, and the database is notified to read it. The database regards the code stream of the target data read from the circular buffer as a database file, and the row data contained in each target data in the database file meets the filtering conditions.

[0099] Through the parallel computing capabilities of the accelerator, filtering, projecting and merging data can significantly improve the efficiency of data processing, especially for large-scale data query and processing tasks. According to the target filtering conditions and projection rules, the parallel computing units in the dedicated hardware (such as: preset accelerator) are used to use multiple pages of parallel computing to more quickly filter out the target data that meets the query conditions, reducing unnecessary data transmission and processing. Data parsing and merging according to the file storage format ensures that the format of the target data is consistent with the storage requirements of the database, improving the compatibility and availability of the data.

[0100] In one implementable manner of the embodiment of the present disclosure, when extracting the target data in the preset accelerator into the database, the following manner may also be adopted but is not limited to: based on the soft connection in the target-oriented link, sequentially read the target data in the preset accelerator, and store the read target data; or, based on the second file handle in the target-oriented link, sequentially read the target data in the preset accelerator, and store the read target data; or, based on the third file handle in the target-oriented link, sequentially read the target data in the preset accelerator, and store the read target data.

[0101] In an embodiment of the present application, the database can read the target data directly through a link pointing to a preset accelerator in a redirection link, thereby realizing efficient and stable data interaction between the database and the accelerator.

[0102] In an implementable manner of the embodiment of the present disclosure, after the query is completed, a reset process needs to be performed. Therefore, after the target data in the preset accelerator is extracted into the database through the target-oriented link, the following method can also be used: the target-oriented link is deleted.

[0103] Further, related to the above-mentioned embodiment, the deletion process of the target-oriented link can also be implemented by but not limited to the following methods: renaming the temporary file to be queried as the file to be queried, and deleting the soft link and the target mapping table; or, deleting the target extended attribute in the added file to be queried, and deleting the first file handle and the second file handle; or, deleting the middle layer in the preset operating system.

[0104] Through targeted deletion processing, the database file system is fully restored to the state before acceleration to avoid residual redirection configuration affecting the correctness of subsequent queries. Timely release of soft links, file handles, middle-layer processes and other system resources to reduce memory overhead and ensure the stability of long-term database operation. Deletion logic is decoupled from creation methods to support unified management of multiple redirection solutions, facilitating subsequent system upgrades or expansion of other acceleration strategies.

[0105] In summary, the embodiments of the present application can achieve the following technical effects: 1. A database hardware acceleration method, electronic device and storage medium of the present application obtains the parameters of the target function in the query process, i.e., query parameter information, by injecting instructions into the target query function in the database, and sends the query parameter information to the accelerator, which processes the data in the data query process according to the query parameters to obtain the target data; through the target-oriented link obtained by redirecting between the database and the accelerator, the target data that meets the target filtering conditions is read from the accelerator, and the technical effect of hardware acceleration can be achieved without modifying the database source code. Therefore, it can solve the technical problems in the related technology that the development of database integrated hardware acceleration function is difficult and different versions of databases need to be maintained separately, so as to achieve the technical effect of database hardware acceleration without modifying the database source code.

[0106] 2. This application uses eBPF technology to achieve non-intrusive expansion of existing database systems. Hardware acceleration support can be added without modifying the database code, avoiding deep customization or secondary development of the database kernel, and reducing implementation costs and complexity.

[0107] 3. This application can use the same set of eBPF loaders and instructions for different versions of the database, without the need to develop separate code for each version and recompile, deploy and run, thereby reducing code development costs and subsequent maintenance and operation costs.

[0108] 4. This application provides a variety of file redirection methods to adapt to different scenarios and system requirements.

[0109] 5. The preset accelerator of this application directly reorganizes the processed results into target data that conforms to the file storage format, and manages it through a circular buffer, so that the database can read it directly, avoiding the need to add additional parsing and conversion code.

[0110] 6. This application supports a variety of database systems and hardware platforms, has good scalability and compatibility, and is easy to promote and apply in different environments.

[0111] 7. The eBPF technology of this application can inject instructions into all database processes, and can distinguish different user processes by querying the process identifier (PID) through the process ID number, so as to realize hardware acceleration of the specified user process.

[0112] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method.

[0113] The embodiment of the present application also provides a database hardware acceleration device, Fig.10 A schematic diagram of the structure of a database hardware acceleration device provided in this application, such as Fig.10 As shown, including: The injection unit 1001 is used to inject a first preset instruction into a target query function of a database in response to a data query instruction; An acquiring unit 1002 is configured to acquire query parameter information of a target query function based on a first preset instruction; A configuration unit 1003 is used to configure the query parameter information into a preset accelerator after re-encoding the data; A directional unit 1004 is used to perform redirection link processing between the database and the preset accelerator based on the address of the file to be queried in the query parameter information to obtain a target directional link, wherein the target directional link at least includes a link pointing to the preset accelerator and a target mapping table corresponding to the address of the file to be queried; The first extraction unit 1005 is used to extract the to-be-queried file in the memory to the accelerator based on the target-oriented link; A filtering unit 1006 is used to filter the query file in the accelerator according to the target filtering condition in the query parameter information to obtain target data. The query file is determined in the memory through the target mapping table in the target directional link; The second extraction unit 1007 is used to extract the target data in the preset accelerator into the database through the target-oriented link.

[0114] In one embodiment of the present application, the injection unit 1001 is also used for: Inserting a first entry code instruction and a first end code instruction into the filter condition generation function in the target query function, wherein the first entry code instruction is at least used to obtain the target filter condition, and the first end code instruction is used to set the return value of the filter condition generation function to a null value; Inserting a second entry code instruction and a second end code instruction into the projection rule generation function in the target query function, wherein the second entry code instruction is at least used to obtain the projection rule in the query parameter information, and the second end code instruction is used to set the return value of the projection rule generation function to a null value; In the scanning function in the target query function, a third entry code instruction is inserted, wherein the third entry code instruction is at least used to obtain the file storage format in the query parameter information and the address of the file to be queried.

[0115] In one embodiment of the present application, the acquisition unit 1002 is further configured to: Obtaining a query process identifier corresponding to each query process executed by the target query function, and performing matching processing in preset target identification information according to multiple query process identifiers to determine multiple target process identifiers, wherein the target process identifier is a query process identifier corresponding to the target query process in the query process, the target query process is a query process to be accelerated, and the preset target identification information includes identification information corresponding to the target query process; Based on the first preset instruction, first parameter information corresponding to each query process is obtained, and the first parameter information is classified and processed according to the target process identifier to obtain the classified first parameter information corresponding to each of the multiple target query processes; When it is determined that any classified first parameter information meets the preset parameter condition, the classified first parameter information meeting the preset parameter condition is determined as the query parameter information.

[0116] In one embodiment of the present application, the orientation unit 1004 is further configured to: Determine the file to be queried in the memory according to the address of the file to be queried; Create a soft link pointing to the preset accelerator according to the file to be queried to obtain a target directional link; or, Adding target extended attributes to the file to be queried, and generating a file handle pointing to the preset accelerator according to the added file to be queried, to obtain a target directional link, wherein the target extended attributes at least include a node file pointing to the preset accelerator; or, An intermediate layer is added between the operation layer and the application layer of a preset operating system, and a target-oriented link is created through the intermediate layer, wherein the preset operating system is a system for executing a database hardware acceleration method.

[0117] In one embodiment of the present application, the orientation unit 1004 is further configured to: Create a soft link pointing to the preset accelerator according to the file to be queried; Rename the file to be queried to obtain a temporary file to be queried, and determine a target mapping table of the temporary file to be queried in the memory according to the address of the temporary file to be queried, wherein the target mapping table is used to determine the position of the temporary file to be queried in the memory, and the address of the temporary file to be queried is the same as the address of the file to be queried; The link determination process is performed according to the target mapping table and the soft connection to obtain the target directional link.

[0118] In one embodiment of the present application, the orientation unit 1004 is further configured to: Perform target extended attribute adding processing on the file to be queried to obtain the added file to be queried; Performing a handle generation process according to the added file to be queried, obtaining a first file handle and a second file handle, wherein the second file handle is a file handle pointing to a preset accelerator, the first file handle is generated according to the file to be queried, and the second file handle is generated according to the node file in the target extended attribute; Determine a target mapping table of the file to be queried in the memory according to the first file handle, wherein the target mapping table is used to determine the file to be queried in the memory, and the first file handle is a file handle pointing to the memory; A link determination process is performed based on the second file handle and the target mapping table to obtain a target-oriented link.

[0119] In one embodiment of the present application, the orientation unit 1004 is further configured to: Adding processing to a process middle layer between an operation layer and an application layer of a preset operating system to obtain a middle layer, wherein the preset operating system is a system for executing a database hardware acceleration method; Generate a database directory based on the files in the storage device and mount the database directory to the middle layer; In the middle layer, a mapping list corresponding to the file to be queried is generated according to the file to be queried and the database directory, and a target mapping table is determined according to the mapping list; In the middle layer, a third file handle pointing to the preset accelerator is created, and a link determination process is performed according to the third file handle and the target mapping table to obtain a target-oriented link.

[0120] In one embodiment of the present application, the first extraction unit 1005 is further used for: Perform file acquisition processing in the memory according to the target mapping table in the target directional link to obtain the file to be queried; Extract the file to be queried into the accelerator.

[0121] In one embodiment of the present application, the filtering unit 1006 is further used for: According to the file storage format, the field positions of the column fields corresponding to the multiple rows of data are parsed from the multiple rows of data in the file to be queried; Based on the field position and the target filtering condition, the column fields that meet the target filtering condition in the column fields corresponding to the multiple rows of data are determined to obtain the target column field; Projecting the row data including the target column field according to the projection rule to obtain projection row data; The projection row data are merged and processed according to the file storage format to obtain the target data; The target data is stored in a circular buffer of a preset accelerator.

[0122] In one embodiment of the present application, the second extraction unit 1007 is further used for: Based on the soft connection in the target oriented link, sequentially read the target data in the preset accelerator, and store the read target data; or, Based on the second file handle in the target-oriented link, sequentially read the target data in the preset accelerator, and store the read target data; or, Based on the third file handle in the target-oriented link, sequential reading processing is performed on the target data in the preset accelerator, and the read target data is stored.

[0123] In one embodiment of the present application, Fig.11 As shown, the database hardware acceleration device also includes: The deleting unit 1008 is used to delete the target directional link.

[0124] In one embodiment of the present application, the deleting unit 1008 is further configured to: Rename the temporary file to be queried to the file to be queried, and delete the soft link and the target mapping table; or, Deleting the target extended attribute in the added file to be queried, and deleting the first file handle and the second file handle; or, The middle layer is deleted in the preset operating system.

[0125] For the description of the features in the embodiment corresponding to the database hardware acceleration device, reference can be made to the relevant description of the embodiment corresponding to the database hardware acceleration method, which will not be repeated here.

[0126] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above database hardware acceleration method embodiments.

[0127] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above-mentioned database hardware acceleration method embodiments when running.

[0128] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0129] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above database hardware acceleration method embodiments are implemented.

[0130] An embodiment of the present application also provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above-mentioned database hardware acceleration method embodiments are implemented.

[0131] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0132] The above is a detailed introduction to a database hardware acceleration method, electronic device and storage medium provided by the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application, and the description of the above embodiments is only used to help understand the method and core idea of ​​the present application. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of the present application.

Claims

1. A database hardware acceleration method, characterized in that: include: In response to the data query instruction, inject a first preset instruction into a target query function of the database, and obtain query parameter information of the target query function based on the first preset instruction; After data re-encoding the query parameter information, the data is configured in a preset accelerator, and a redirection link process is performed between the database and the preset accelerator based on the address of the file to be queried in the query parameter information to obtain a target-oriented link, wherein the target-oriented link at least includes a link pointing to the preset accelerator and a target mapping table corresponding to the address of the file to be queried; Extracting the to-be-queried file in the memory into the accelerator based on the target-oriented link, and filtering the to-be-queried file in the accelerator according to the target filtering condition in the query parameter information to obtain target data, wherein the to-be-queried file is determined in the memory through the target mapping table in the target-oriented link; The target data in the preset accelerator is extracted into the database through the target-oriented link.

2. The database hardware acceleration method according to claim 1, characterized in that: In response to the data query instruction, injecting the first preset instruction into the target query function of the database includes: Inserting a first entry code instruction and a first end code instruction into the filter condition generation function in the target query function, wherein the first entry code instruction is at least used to obtain the target filter condition, and the first end code instruction is used to set the return value of the filter condition generation function to a null value; Inserting a second entry code instruction and a second end code instruction into the projection rule generation function in the target query function, wherein the second entry code instruction is at least used to obtain the projection rule in the query parameter information, and the second end code instruction is used to set the return value of the projection rule generation function to a null value; In the scanning function in the target query function, a third entry code instruction is inserted, wherein the third entry code instruction is at least used to obtain the file storage format in the query parameter information and the address of the file to be queried.

3. The database hardware acceleration method according to claim 2, characterized in that: The acquiring the query parameter information of the target query function based on the first preset instruction includes: Obtaining a query process identifier corresponding to each query process executed by the target query function, and performing matching processing in preset target identification information according to the multiple query process identifiers to determine multiple target process identifiers, wherein the target process identifier is a query process identifier corresponding to a target query process in the query process, the target query process is a query process to be accelerated, and the preset target identification information includes identification information corresponding to the target query process; Based on the first preset instruction, first parameter information corresponding to each query process is obtained, and the first parameter information is classified according to the target process identifier to obtain classified first parameter information corresponding to each of the plurality of target query processes; In the case where it is determined that any of the classified first parameter information meets the preset parameter condition, the classified first parameter information that meets the preset parameter condition is determined as the query parameter information.

4. The database hardware acceleration method according to claim 2, characterized in that: The redirection link processing is performed between the database and the preset accelerator based on the address of the file to be queried in the query parameter information to obtain the target directional link, including: Determine the file to be queried in the memory according to the address of the file to be queried; Create a soft link pointing to the preset accelerator according to the file to be queried to obtain the target directional link; or, Adding a target extended attribute to the file to be queried, and generating a file handle pointing to the preset accelerator according to the added file to be queried, to obtain the target directional link, wherein the target extended attribute at least includes a node file pointing to the preset accelerator; or, An intermediate layer is added between the operation layer and the application layer of a preset operating system, and the target-oriented link is created through the intermediate layer, wherein the preset operating system is a system for executing the database hardware acceleration method.

5. The database hardware acceleration method according to claim 4, characterized in that: The step of creating a soft link pointing to the preset accelerator according to the file to be queried to obtain the target directional link comprises: Creating a soft link pointing to the preset accelerator according to the file to be queried; Rename the file to be queried to obtain a temporary file to be queried, and determine the target mapping table of the temporary file to be queried in the memory according to the address of the temporary file to be queried, wherein the target mapping table is used to determine the position of the temporary file to be queried in the memory, and the address of the temporary file to be queried is the same as the address of the file to be queried; A link determination process is performed according to the target mapping table and the soft connection to obtain the target directional link.

6. The database hardware acceleration method according to claim 5, characterized in that: The step of adding a target extended attribute to the file to be queried, and generating a file handle pointing to the preset accelerator according to the added file to be queried, to obtain the target directional link includes: Performing target extended attribute adding processing on the file to be queried to obtain the added file to be queried; Performing a handle generation process according to the added file to be queried to obtain a first file handle and a second file handle, wherein the second file handle is a file handle pointing to the preset accelerator, the first file handle is generated according to the file to be queried, and the second file handle is generated according to the node file in the target extended attribute; Determining the target mapping table of the file to be queried in the memory according to the first file handle, wherein the target mapping table is used to determine the file to be queried in the memory, and the first file handle is a file handle pointing to the memory; A link determination process is performed according to the second file handle and the target mapping table to obtain the target oriented link.

7. The database hardware acceleration method according to claim 6, characterized in that: The adding of an intermediate layer between the operation layer and the application layer of the preset operating system and creating the target-oriented link through the intermediate layer includes: Adding a process in an intermediate layer between the operation layer and the application layer of the preset operating system to obtain the intermediate layer, wherein the preset operating system is a system for executing the database hardware acceleration method; Generate a database directory according to the files in the memory, and mount the database directory to the middle layer; In the middle layer, a mapping list corresponding to the file to be queried is generated according to the file to be queried and the database directory, and the target mapping table is determined according to the mapping list; In the middle layer, a third file handle pointing to the preset accelerator is created, and a link determination process is performed according to the third file handle and the target mapping table to obtain the target-oriented link.

8. The database hardware acceleration method according to claim 7, characterized in that: The extracting the to-be-queried file in the memory to the accelerator based on the target-oriented link comprises: Perform file acquisition processing in the memory according to the target mapping table in the target oriented link to obtain the file to be queried; The file to be queried is extracted into the accelerator.

9. The database hardware acceleration method according to claim 2, characterized in that: The filtering process of the to-be-queried file in the accelerator according to the target filtering condition in the query parameter information to obtain the target data includes: Parsing, according to the file storage format, from a plurality of rows of data in the file to be queried, the field positions of the column fields corresponding to the plurality of rows of data; Based on the field position and according to the target filtering condition, the column fields in the column fields corresponding to the plurality of rows of data that meet the target filtering condition are determined to obtain the target column field; Projecting the row data including the target column field according to the projection rule to obtain projection row data; Merge the projection row data according to the file storage format to obtain the target data; The target data is stored in a circular buffer of the preset accelerator.

10. The database hardware acceleration method according to claim 7, characterized in that: The extracting the target data in the preset accelerator into the database through the target-oriented link comprises: Based on the soft connection in the target-oriented link, sequentially read the target data in the preset accelerator, and store the read target data; or, Based on the second file handle in the target-oriented link, sequentially read the target data in the preset accelerator, and store the read target data; or, Based on the third file handle in the target-oriented link, the target data in the preset accelerator is sequentially read and stored.

11. The database hardware acceleration method according to claim 10, characterized in that: After extracting the target data in the preset accelerator into the database through the target-oriented link, the method further includes: The target directional link is deleted.

12. The database hardware acceleration method according to claim 11, characterized in that: The deleting process of the target directional link comprises: rename the temporary file to be queried to the file to be queried, and delete the soft link and the target mapping table; or, Deleting the target extended attribute in the added file to be queried, and deleting the first file handle and the second file handle; or, The intermediate layer is deleted in the preset operating system.

13. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the database hardware acceleration method according to any one of claims 1 to 12 when executing the computer program.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the database hardware acceleration method according to any one of claims 1 to 12.

15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the database hardware acceleration method according to any one of claims 1 to 12 are implemented.

Citation Information

Patent Citations

  • Method and device for accelerating database operation

    CN113448967A

  • Volatile database caching in database accelerator

    CN117043763A

  • Logic design system for controller hardware acceleration

    CN119806644A

  • Apparatus, method and storage medium for database query

    US20240184784A1