Database Hardware Acceleration Method, Electronic Device, and Storage Medium

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

CN120030051BActive Publication Date: 2025-06-27INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The development of existing database hardware acceleration methods is difficult and requires separate maintenance for different versions of databases.

Method used

By injecting preset instructions into the database's target query function, obtaining query parameter information, reencode it and configure it into the preset accelerator, realizing the redirect link between the database and the accelerator, extracting and filtering the data, and finally returning the result to the database.

Benefits of technology

It realizes hardware acceleration without modifying the database source code, solving the problem of the difficulty of developing database integrated hardware acceleration functions and the need to maintain separate databases for different versions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120030051B_ABST
    Figure CN120030051B_ABST
Patent Text Reader

Abstract

The present application discloses a database hardware acceleration method, an electronic device, and a storage medium, relating to the field of computer technologies. By injecting instructions into a target query function in the database, the parameters of the target function in the query process, that is, query parameter information, are obtained, and the query parameter information is sent to an accelerator. The accelerator processes the data query process according to the query parameters to obtain target data. Through a target redirection link obtained by redirecting between the database and the accelerator, the target data that meets the target filtering conditions is read from the accelerator, achieving the technical effect of hardware acceleration without modifying the database source code. Therefore, the technical problems in the related technologies that the development difficulty of the database integrated hardware acceleration function is large and separate maintenance is required for different versions of the database can be solved, and the technical effect of realizing the hardware acceleration of the database without modifying the database source code can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of information technology, higher requirements are imposed on the performance of databases in fields such as big data, cloud computing, and artificial intelligence. As the core of information processing, the performance of a database directly affects the operating efficiency of the entire application. However, traditional databases often encounter performance bottlenecks when processing massive amounts of data and high-concurrency requests. To solve this problem, database hardware acceleration methods have emerged.

[0003] In the prior art, database hardware acceleration methods generally integrate hardware acceleration functions into the database. Usually, it is necessary to modify the database source code or implement it by means of a plug-in mechanism, and then write specific version code adapted thereto. Therefore, in the prior art, there are problems such as the difficulty in developing the database integrated hardware acceleration function and the need for separate maintenance for different versions of the database. Summary of the Invention

[0004] This application provides a database hardware acceleration method, an electronic device, and a storage medium to at least solve the problems in the related art that the development of the database integrated hardware acceleration function is difficult and separate maintenance is required for different versions of the database.

[0005] This application provides a database hardware acceleration method, which includes:

[0006] In response to a data query instruction, inject a first preset instruction into the target query function of the database, and obtain the query parameter information of the target query function based on the first preset instruction;

[0007] After re-encoding the query parameter information, configure it into a preset accelerator, and perform a redirect link process 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 redirect link, where the target redirect 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;

[0008] Extract the file to be queried in the memory to the accelerator based on the target redirect link, and filter the file to be queried in the accelerator according to the target filtering condition in the query parameter information to obtain target data, and the file to be queried is determined in the memory through the target mapping table in the target redirect link;

[0009] Extract the target data in the preset accelerator to the database through the target redirect link.

[0010] The present application also provides a database hardware acceleration device, including:

[0011] 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;

[0012] An acquisition unit, configured to acquire query parameter information of the target query function based on the first preset instruction;

[0013] A configuration unit, configured to re-encode the query parameter information and then configure it into a preset accelerator;

[0014] An orientation unit, configured to perform a redirect link process 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 redirect link, where the target redirect 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;

[0015] A first extraction unit, configured to extract the file to be queried in the memory to the accelerator based on the target redirect link;

[0016] A filtering unit, configured to filter the file to be queried in the accelerator according to a target filtering condition in the query parameter information to obtain target data, and the file to be queried is determined in the memory through the target mapping table in the target redirect link;

[0017] A second extraction unit, configured to extract the target data in the preset accelerator to the database through the target redirect link.

[0018] The present application also provides an electronic device, including: a memory, configured to store a computer program; a processor, configured to implement the steps of any one of the above database hardware acceleration methods when executing the computer program.

[0019] The present application also provides a computer-readable storage medium, in which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any one of the above database hardware acceleration methods.

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

[0021] Through this application, due to a database hardware acceleration method, an electronic device, and a storage medium, by injecting instructions into a target query function in the database to obtain the parameters of the target function in the query process, that is, query parameter information, and sending the query parameter information to an accelerator, the accelerator processes the data query according to the query parameters to obtain target data; through a target redirection link obtained by redirecting between the database and the accelerator, reading the target data that meets the target filtering conditions from the accelerator, the technical effect of hardware acceleration can be achieved without modifying the database source code. Therefore, the technical problems in the related art that the development of the database integrated hardware acceleration function is difficult and needs to be separately maintained for different versions of the database can be solved, and the technical effect of realizing the hardware acceleration of the database without modifying the database source code can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] To more clearly illustrate the embodiments of the present application, the following will briefly introduce the drawings required in the embodiments. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained based on these drawings.

[0023] Figure 1 Schematic flowchart of a database hardware acceleration method provided by an embodiment of the present application;

[0024] Figure 2 General schematic diagram of a database hardware acceleration method provided by an embodiment of the present application;

[0025] Figure 3 Schematic diagram of obtaining query parameter information provided by an embodiment of the present application;

[0026] Figure 4 Example diagram of redirection processing based on a soft link provided by an embodiment of the present application;

[0027] Figure 5 Example diagram of redirection processing based on adding a target extended attribute provided by an embodiment of the present application;

[0028] Figure 6 Example diagram of redirection processing based on an intermediate layer provided by an embodiment of the present application;

[0029] Figure 7 Example diagram of a preset accelerator provided by an embodiment of the present application;

[0030] Figure 8 Example diagram of target data provided by an embodiment of the present application;

[0031] Figure 9An example diagram for obtaining target data in a preset accelerator provided by an embodiment of the present application;

[0032] Figure 10 A schematic structural diagram of a database hardware acceleration device provided by an embodiment of the present application;

[0033] Figure 11 A schematic structural diagram of another database hardware acceleration device provided by an embodiment of the present application. Detailed implementation manners

[0034] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

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

[0036] To enable those skilled in the art of the present technology to better understand the solution of the present application, the present application will be further described in detail below in conjunction with the accompanying drawings and specific implementation manners.

[0037] Figure 1 A flowchart of a database hardware acceleration method provided by an embodiment of the present application. In combination with the execution process of the database hardware acceleration method, the method will be described in detail.

[0038] As Figure 1 shown, the database hardware acceleration method includes:

[0039] Step 101, in response to a 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.

[0040] In an embodiment of the present application, the data query instruction is a query instruction input by a user who needs to perform 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, such as: Berkeley Packet Filter (BPF) instructions under the Extended Berkeley Packet Filter (eBPF) technology, etc. Specifically, the type of the first preset instruction is not limited in the present application.

[0041] Among them, the database is a custom-selected database, and the database types include but are not limited to: MySQL, Oracle, SQL Server, PostgreSQL, etc. Specifically, the type of the database is not limited in the present application.

[0042] For ease of understanding, the subsequent database will be described by taking the PostgreSQL type as an example.

[0043] The target query function is the core function for the database to perform data scanning (including at least: the ExecSeqScan function of PostgreSQL, 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.

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

[0045] Further, when injecting the first preset instruction and obtaining the query parameter information, this operation can be performed through a preset loader, such as: the BPF loader, etc. For ease of understanding the implementation process of the present application, the subsequent first preset instruction will be described by taking the BPF instruction as an example, and the preset loader will be described by taking the BPF loader as an example.

[0046] Specifically, regarding the implementation process of the present application, the embodiment of the present application provides a general schematic diagram of a database hardware acceleration method, as Figure 2As shown in the figure, the injection of the first preset instruction and the acquisition of query parameter information can be expressed as follows: Through the BPF loader 201, the BPF program 202 is compiled into BPF instructions 205 and injected into the target query function 204 of the database 203. A BPF map structure 206 is included in the BPF instructions for obtaining query parameter information 207. The BPF loader obtains the query parameter information 207 by listening to the BPF map structure 206.

[0047] Step 102: After data re-encoding the query parameter information, configure it into a preset accelerator, and perform redirect link processing between the database and the preset accelerator based on the file address to be queried in the query parameter information to obtain a target directed link, where the target directed link at least includes a link pointing to the preset accelerator and a target mapping table corresponding to the file address to be queried.

[0048] In the embodiments of the present application, data re-encoding refers to converting specific data structures in the database (such as: tree-like expressions of qual, column format descriptions of tupdesc) into a flattened instruction sequence that can be loaded by the preset accelerator. For example: encoding the operator hierarchy relationship in the filtering condition into a combination of bit masks and operation codes, encoding the storage format of column fields into an array of type identifiers and offsets, etc.

[0049] Among them, the preset accelerator is an accelerator selected customarily, such as: a Field-Programmable Gate Array (FPGA) hardware accelerator, etc. Specifically, the present application does not limit the preset accelerator.

[0050] Accelerator configuration means writing the re-encoded query parameter information into the preset accelerator through the preset operating system kernel. The redirect link processing modifies the access path of the database to the file so that it points to the virtual device node of the accelerator. 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 file address to be queried. When the database process accesses through the file address to be queried, it actually reads the data in the accelerator.

[0051] Extended attribute mapping: Add extended attributes to the file to be queried to record the node file pointing to the accelerator. During the file opening operation, intercept the system call to open the file to be queried and the node file of the accelerator simultaneously, and associate the node file handle of the accelerator with the private data area of the file handle of the file to be queried to achieve a seamless redirect of read and write operations.

[0052] The target directed link contains two core elements:

[0053] Link pointing to the accelerator: used to route file read requests of the database to the accelerator;

[0054] Target mapping table: records the mapping relationship between the logical blocks and physical blocks of the file to be queried in the memory, for the accelerator to directly access the file to be queried in the memory according to the physical address.

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

[0056] Among them, the preset operating system is a custom-selected system for executing the database hardware acceleration method, for example: linux system, etc. Specifically, the present application does not limit the preset operating system.

[0057] Step 103, extract the file to be queried in the memory to the accelerator based on the target-oriented link, and filter the file to be queried 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-oriented link.

[0058] In the 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 memory (such as: 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: extracting row data from the file to be queried according to the file storage format to generate a row data tuple; a filtering module: performing a logical judgment on each row of data according to the target filtering condition, and only retaining the rows that meet the conditions; a projection module: extracting specified columns from the filtered rows according to the projection rule to generate a refined data set; a merging module: reassembling the processed data according to the file storage format to obtain the target data and writing it into the circular buffer.

[0059] Among them, the target data is the data that needs to be queried. Specifically, as Figure 2 shown, when determining the data to be queried and filtering the file to be queried 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 the data that meets the conditions, that is, the target data.

[0060] Step 104, extract the target data in the preset accelerator to the database through the target-oriented link.

[0061] In an embodiment of the present application, when the database accesses the preset accelerator through the redirect link, the actually read target data is in the circular buffer of the preset accelerator. Since the target data is completely 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 considers that all target data meets the target filtering conditions, thus skipping the original software calculation process.

[0062] Specifically, as Figure 2 shown, when extracting the target data in the preset accelerator to 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 redirect link.

[0063] A database hardware acceleration method, an electronic device, and a storage medium of the present application obtain the parameter information of the target function in the query process, that is, the query parameter information, by injecting instructions into the target query function in the database, send the query parameter information to the accelerator, and the accelerator processes 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, read the target data that meets the target filtering conditions from the accelerator, achieving the technical effect of hardware acceleration without modifying the database source code. Therefore, it can solve the technical problems in the related art that the development of the database integrated hardware acceleration function is difficult and requires separate maintenance for different versions of the database, and achieve the technical effect of hardware acceleration of the database without modifying the database source code. And it supports dynamically adding hardware acceleration functions (the acceleration functions of the preset accelerator) during the operation of the database, without restarting the program and performing cumbersome operations such as compilation, configuration, and deployment.

[0064] In an implementable manner of the embodiment of the present disclosure, the form of the target query function is a statement form selected customarily. For example, it is usually represented in the form of an SQL statement. For the sake of understanding, the target query function will be described by taking the SQL statement form as an example hereinafter. At this time, the form of the target query function includes but is not limited to: select the name of the selected field, from the name of the database table, where the target filtering condition, that is, through the select clause, select the column fields 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 for the column fields.

[0065] It should be noted that when the database executes the target query function to perform data query, it will execute but is not limited to the following steps:

[0066] (1) Based on 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, i.e., 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 relational file node to be queried.

[0067] (2) According to the WHERE clause, read the row data from the file to be queried one by one, and parse the column fields of the row data according to the file storage format; according to the target filtering conditions, perform filtering on the column fields. The file storage format is stored in the function entry parameter: tuple descriptor; the target filtering conditions are stored in the entry parameter: target filtering conditions. The filtering calculation corresponds to a sub-function of the filtering condition generation function. If the target filtering conditions are not empty, execute this sub-function, and after the calculation is completed, return the row data that meets the target filtering conditions.

[0068] (3) According to the SELECT clause, extract the column fields. For the row data that meets the target filtering conditions, perform projection calculation to extract the target column fields. The index numbers required to extract the column fields are stored in the entry parameter: projection information. The projection calculation corresponds to a sub-function of the projection rule generation function. After the calculation is completed, extract the target column fields from the row data that meets the target filtering conditions and reassemble them into a new row data, i.e., the target data.

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

[0070] At this time, it can be seen that the target query function includes multiple functions, namely, the filtering condition generation function, the projection rule generation function, and the scanning function. Therefore, when injecting the first preset instruction, a section of instructions will be injected into different functions in the target query function. That is, the first preset instruction also includes multiple types of instructions. Therefore, when injecting the first preset instruction into the target query function of the database, the following methods can be used but are not limited to: in the filtering condition generation function of the target query function, insert the first entry code instruction and the first end code instruction, where the first entry code instruction is at least used to obtain the target filtering condition, and the first end code instruction is used to set the return value of the filtering condition generation function to a null value; in the projection rule generation function of the target query function, insert the second entry code instruction and the second end code instruction, where 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 of the target query function, insert the third entry code instruction, where the third entry code instruction is at least used to obtain the file storage format and the file address to be queried in the query parameter information.

[0071] In the embodiments of the present application, for the specific method of instruction injection, the following methods can be used but are not limited to: at the entry position of the filtering condition generation function in the target query function, insert the first entry code instruction, where the first entry code instruction is at least used to obtain the target filtering condition, and the target query function at least includes the filtering condition generation function, the projection rule generation function, and the scanning function; at the end position of the filtering condition generation function, insert the first end code instruction, where the first end code instruction is used to set the return value of the filtering condition generation function to a null value; at the entry position of the projection rule generation function, insert the second entry code instruction, where the second entry code instruction is at least used to obtain the projection rule in the query parameter information, and 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 the second end code instruction, where 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 the third entry code instruction, where 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 the first entry code instruction, the first end code instruction, the second entry code instruction, the second end code instruction, and the third entry code instruction.

[0072] The forms of the first entry code instruction, the second entry code instruction, and the third entry code instruction are instruction forms set by customization. For example: uprobes injection instructions, etc. The forms of the first end code instruction and the second end code instruction are also instruction forms set by customization. For example: uretprobes injection instructions, etc.

[0073] At this time, for injecting the first preset instruction into the target query function, the following methods can also be adopted but are not limited to: at the entry position of the filter condition generation function, use the uprobes injection instruction to obtain the target filter condition. At the end position of the filter condition generation function, use the uretprobes injection instruction to set the return value to be empty. At the entry position of the projection rule generation function, use the uprobes injection instruction to obtain the projection rule. At the end position of the projection rule generation function, use the uretprobes injection instruction to set the return value to be empty. At the entry position of the scan function, use the uprobes injection instruction to obtain the address of the file to be queried and the file storage format.

[0074] Specifically, for the implementation process of the embodiments of the present application, it can also be illustrated by the following examples:

[0075] (1) At the entry position of the filter condition generation function (ExecInitQual function), inject an instruction through the uprobes 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, obtain the comparison operations and logical operators in the filter condition generation function, and then the target filter condition can be obtained.

[0076] (2) At the end position of the ExecInitQual function, through the uretprobes mount point of the BPF loader, set the return value to be empty. After setting the return value to be empty, in the input parameters of the scan function (ExecSeqScan), the return value of the target filter condition is empty, and the scan function will not execute the parsing filter calculation, thus ensuring that the data is filtered only once.

[0077] (3) At the entry position of the projection rule generation function (ExecBuildProjectionInfo function), inject an instruction through the uprobes mount point of the BPF loader to obtain the projection rule in the query parameter information, and then obtain the index numbers of the column fields in the file to be queried.

[0078] (4) At the end of the ExecBuildProjectionInfo function, set the return value to be empty through the uretprobe mount point of the BPF loader. After setting the return value to be empty, in the input parameters of the scan function (ExecSeqScan), the return value of the projection rule is empty, and the scan function will not perform projection calculation, thus ensuring that the data is projected only once.

[0079] (5) At the entry position of the scan function (ExecSeqScan function), inject instructions through the uprobe mount point of the BPF loader. In the scan function, the storage path of the file to be queried in the memory, i.e., 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.

[0080] For other types of databases, such as MySQL, Oracle, SQLServer, etc., only the function names change and the data structures are adjusted accordingly. The above process can be adopted to achieve the same technical effect, that is, the database hardware acceleration method can be applied to multiple types of databases. Specifically, the embodiments of this application do not limit this.

[0081] Through the eBPF probe technology, query parameter information can be obtained in real time at the function-level granularity without parsing SQL statements or relying on database internal logs, ensuring the accuracy and real-time nature of data collection; by modifying the function return value instead of directly intervening in the code logic, the database can skip repeated calculations, maintain the integrity of the native execution process, and avoid compatibility problems caused by code modification; extract the filtering and projection parameters in advance to the initial stage of function execution, strive for a time window for subsequent accelerator configuration, ensure that the hardware resources are initialized before the query starts, and achieve seamless connection of computing tasks; regardless of how the database type (PostgreSQL, MySQL, Oracle, etc.) changes, only adjust the target function name and the data structure parsing method (e.g., the function name for generating filtering conditions in MySQL is different), and the same set of instruction injection logic can be reused to significantly reduce the adaptation cost of different databases and different versions of the same database.

[0082] In an implementable manner of the embodiments of the present disclosure, for the process of obtaining the query parameter information of the target query function, it can also be implemented by, but not limited to, the following method: obtaining the query process identifier corresponding to each query process executed by the target query function, and performing a matching process in the preset target identifier information according to multiple query process identifiers to determine multiple target process identifiers, where the target process identifier is the query process identifier corresponding to the target query process in the query process, and the target query process is the query process to be accelerated, and the preset target identifier information includes the identifier information corresponding to the target query process; obtaining the first parameter information corresponding to each query process based on the first preset instruction, and classifying the first parameter information 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 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.

[0083] In the embodiments of the present application, the database provides services for multiple users. When each user logs in and performs a data query, a query process will be created, which has a unique process identification code (Identifier, ID) number, that is, the query process identifier (PID). In the database query process, when the target query function injecting the first preset instruction is executed, the execution of the first preset instruction will be triggered. For the same query process, the target query function will be executed one by one, that is, the filter condition generation function, the projection rule generation function, and the scan function will be triggered in sequence, and the scan function will be executed repeatedly.

[0084] Among them, the preset parameter condition is a condition set by the user. For example: whether all parameters are collected, etc. Specifically, the embodiments of the present application do not limit the preset parameter condition.

[0085] Specifically, when obtaining the query parameter information, it is not necessary to obtain the query parameter information of all query processes. Only the query parameter information of the query process to be accelerated, that is, the target query process, needs to be obtained. Among them, the preset target identifier information is information set by the user, which records the white list of the process ID numbers supporting hardware acceleration, that is, the identifier of the target query process. At this time, through the query process identifier and the preset target identifier information, the target process identifier corresponding to the target query process can be determined, and then the query parameter information can be obtained according to the target process identifier.

[0086] Specifically, regarding the implementation process of this application, the following method can also be adopted: Obtain a whitelist of process IDs that support hardware acceleration, that is, preset target identification information. Each user will log in to the database using a username or user ID, and the database will create a corresponding query process and assign a process ID, that is, a query process identifier (PID). A whitelist can be set to support the hardware acceleration function for the query process identifiers created by users in a specified user group;

[0087] Monitor the BPF map structure, and classify and summarize the obtained parameter information corresponding to the query process according to the target process identifier. For example: classify and summarize the query parameter information collected by the BPF map using the key-value structure according to the target process identifier;

[0088] Determine whether there is a target query process and collect all query parameters (that is, the preset parameter condition is to collect all parameters). If there is, obtain the query parameter information based on 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.

[0089] For ease of understanding, the embodiment of this application provides a schematic diagram for obtaining query parameter information, as Figure 3 shown. Suppose there are three users (User 1, User 2, and User 3) logging in to 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, that is, a query process identifier (PID). By injecting the first preset instruction into each process, the parameters of the target function in each process are collected through monitoring in the BPF loader. For the user corresponding to the query process identifier, the process with special privileges (VIP), that is, the target query process. When all the parameters required for a query are collected, the hardware accelerator is started. For example: Figure 3 In, for the user with the target process identifier of 1001, the classified first parameter information includes the file path (the address of the file to be queried), the storage format (the file storage format), the filtering condition (the target filtering condition), and the projection rule, indicating that all the parameters required for a query are collected at this time.

[0090] The data query process executed in the target query process is parsed, filtered, and projected by the hardware for calculation operations, and the process only needs to read the redirected file. Thus, hardware acceleration for a specific user group is achieved.

[0091] 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. Classifying the first parameter information makes the parameter information of each target query process clearer and more organized, facilitating subsequent processing and use. By determining whether the classified first parameter information meets the preset parameter conditions, the effectiveness and integrity of the query parameter information for hardware acceleration are ensured, and the success rate and efficiency of hardware acceleration processing are improved. The preset target identifier information and preset parameter conditions can be adjusted according to different application scenarios and requirements, making the system have good flexibility and scalability.

[0092] Furthermore, it should be noted that after data re-encoding the query parameter information and configuring it into the preset accelerator, the following methods can also be used but are not limited to:

[0093] (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. Extract the column field length and column field type, encode them into a continuous array, and configure them into the preset accelerator.

[0094] (2) The target filtering condition is a data structure of a linked list + binary tree. The linked list represents the logical operations in the filtering condition, and the binary tree represents the comparison operations. Sequentially traverse each node on the linked list + binary tree, extract the calculation parameter information therein, encode it as a filtering instruction, and configure it into the preset accelerator.

[0095] (3) The projection rule is a linked list structure that contains the column index numbers selected in the select clause. Extract the column index numbers, encode them as column field extraction numbers, and configure them into the preset accelerator.

[0096] (4) Different files to be queried have different storage format conventions. Encode the storage format convention information as a number and configure it into the preset accelerator.

[0097] In an implementable manner of the embodiments of the present disclosure, regarding the redirection link processing, the following manner can also be adopted but is not limited thereto: 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 a preset accelerator according to the file to be queried to obtain a target redirection link; or, performing target extended attribute addition processing on the file to be queried, and generating a file handle pointing to the preset accelerator according to the file to be queried after the addition to obtain a target redirection link, where 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 a preset operating system, and creating a target redirection link through the intermediate layer, where the preset operating system is a system for executing the database hardware acceleration method.

[0098] Specifically, related to the above embodiments, when creating a soft link pointing to a preset accelerator to obtain a target redirection link, the following manner can also be adopted but is not limited thereto: creating a soft link pointing to a preset accelerator according to the file to be queried; performing a renaming process on 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 according to the address of the temporary file to be queried, where the target mapping table is used to determine the location 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 according to the target mapping table and the soft link to obtain a target redirection link.

[0099] In the embodiments of the present application, the following manner can also be adopted but is not limited thereto: renaming the database table file (file to be queried) to a temporary table file (temporary file to be queried). Creating 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. Obtaining the logical block and physical block mapping table of the temporary file to be queried in the disk, that is, the target mapping table. Passing the target mapping table as a parameter to the preset accelerator.

[0100] For ease of understanding, the embodiments of the present application provide an example diagram of redirection processing based on a soft link, as Figure 4 shown, where 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 redirection link processing includes but is not limited to:

[0101] (1) Rename / database / table.bin to / tmp / table_for_fpga.bin. Execute the command under the preset operating system: mv / database / table.bin / tmp / table_for_fpga.bin.

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

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

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

[0105] Through the process redirection link processing in the form of a symbolic link, no code modification is required, and users can achieve it through the command line, reducing the complexity of the redirection link processing.

[0106] Further, when generating a file handle pointing to the preset accelerator based on the to-be-query file after addition to obtain the target directed link, the following methods can also be used but are not limited to: performing target extended attribute addition processing on the to-be-query file to obtain the to-be-query file after addition; performing handle generation processing based on the to-be-query file after addition to obtain the first file handle and the second file handle, where the second file handle is the file handle pointing to the preset accelerator, the first file handle is generated based on the to-be-query file, and the second file handle is generated based on the node file in the target extended attribute; determining the target mapping table of the to-be-query file in the memory according to the first file handle, where the target mapping table is used to determine the to-be-query file in the memory, and the first file handle is the file handle pointing to the memory; performing link determination processing according to the second file handle and the target mapping table to obtain the target directed link.

[0107] In the embodiments of the present application, the following methods can also be used but are not limited to: adding target extended attributes to the to-be-query file. For example: additional meta-information can be set for the to-be-query file in the form of key-value through the command line. The content of the target extended attribute is the node file created by the accelerator driver, that is, the node file pointing to the preset accelerator.

[0108] Open the to-be-query file after addition to generate two file handles, the first file handle and the second file handle. Use the second file handle generated from the node file in the target extended attribute as the private data of the first file handle generated from the to-be-query file. During the database read operation, replace it with reading the second file handle. In the read function of the accelerator, obtain the mapping table of the logical blocks and physical blocks, that is, the target mapping table, through the first file handle.

[0109] For ease of understanding, the embodiments of the present application provide an example diagram for redirect processing based on adding target extended attributes, as Figure 5 shown. Assume 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 redirect link processing includes but is not limited to:

[0110] (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 under the preset operating system: setfattr -n "user.target_path" -v " / dev / fpga_cu0" / database / table.bin

[0111] (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 attribute 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 attribute 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.

[0112] (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. file_fpga can be obtained through its private member variable. In subsequent read operations, use the file handle of file_fpga to replace the file handle of file_table to read the file data.

[0113] (4) In the read operation function of the preset accelerator, pass in the file handle of file_table as a parameter. Through the file handle of file_table, the physical block position where / database / table.bin is stored on the disk, that is, the target mapping table, can be obtained, and then the file to be queried is loaded from the disk into the accelerator.

[0114] By performing redirection processing based on target extended attribute addition, it is possible to avoid damaging the file storage path in the existing file system and prevent the risk of file system anomalies caused by accidental power failure. When reading data, the file handle is redirected to a preset accelerator; when writing data, the original file handle is still used, supporting read and write operations on the file to be queried simultaneously.

[0115] Furthermore, when creating a target-oriented link through the middle layer, the following methods can be adopted but are not limited to: adding processing between the operation layer and the application layer of the preset operating system to obtain the middle layer, where the preset operating system is the system that executes the database hardware acceleration method; generating a database directory based on the files in the memory and mounting the database directory to the middle layer; in the middle layer, generating a mapping list corresponding to the file to be queried based on the file to be queried and the database directory, and determining the target mapping table based on the mapping list; in the middle layer, creating a third file handle pointing to the preset accelerator and performing link determination processing based on the third file handle and the target mapping table to obtain the target-oriented link.

[0116] In the embodiments of the present application, the following methods can also be adopted but are not limited to: adding a middle layer between the operation layer and the application layer of the preset operating system. The preset operating system can form a middle layer through the Filesystem in Userspace (FUSE) mechanism or the stacked file system, and developers can customize the processing logic in the middle layer.

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

[0118] For ease of understanding, the embodiments of the present application provide an example diagram of redirection processing based on the middle layer, as Figure 6 shown, where the process of performing redirection link processing includes but is not limited to:

[0119] (1) Create a middle layer file system between the operation layer and the application layer. For example: develop a user-mode file system using the FUSE framework of the preset operating system.

[0120] (2) Mount the database directory to the middle layer directory. Use the command line in the preset operating system: mount -tfuse database database_media. All user read and write operations are performed in the middle layer directory (the 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.

[0121] (3) Scan all file paths in the database, use the file paths as parameters, and pass them to the middle layer. At the same time, open the third file handle of the preset accelerator in the middle layer.

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

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

[0124] In an implementable manner of the embodiment of the present disclosure, when extracting the file to be queried in the memory to the accelerator, the following manner can also be adopted but is not limited to: perform file acquisition processing in the memory according to the target mapping table in the target directed link to obtain the file to be queried; extract the file to be queried to the accelerator.

[0125] In the embodiment of the present application, the preset accelerator can directly obtain the storage information of the file to be queried according to the target mapping table. When 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.

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

[0127] In an implementable manner of the embodiments of the present disclosure, when filtering the file to be queried, the following methods may also be used but are not limited thereto: Parse the field positions of the column fields corresponding to each of the multiple line data in the file to be queried according to the file storage format; Based on the field positions, determine the column fields that meet the target filtering conditions among the column fields corresponding to each of the multiple line data according to the target filtering conditions, to obtain the target column fields; Perform projection processing on the line data including the target column fields according to the projection rules, to obtain the projected line data; Perform merging processing on the projected line data according to the file storage format, to obtain the target data; Store the target data in the circular buffer of the preset accelerator.

[0128] In the embodiments of the present application, after the preset accelerator obtains the file to be queried, the file to be queried will be distributed in chunks to the computing pipelines of the preset accelerator, and each pipeline will perform the parsing, filtering, projection, and finally output to the merging module of the data of the file to be queried in parallel. According to the file storage format, assemble the projection results (projected line data) that meet the target filtering conditions into the target data. Output the target data to the circular buffer. When the pipeline is set to stop working, output the target data to the circular buffer.

[0129] Further, for the sake of understanding, the embodiments of the present application provide an example diagram of a preset accelerator, as Figure 7 shown, the preset accelerator includes: a plurality of computing units, a circular buffer, and a message notification unit. Each computing unit includes a plurality of pipelines for parallel computing, and each pipeline includes a parsing module, a filtering module, a projection module, and a merging module.

[0130] The parsing module is used to parse the field positions of the column fields corresponding to each of the multiple line data in the file to be queried according to the file storage format;

[0131] The filtering module is used to determine the column fields that meet the target filtering conditions among the column fields corresponding to each of the multiple line data according to the target filtering conditions based on the field positions, to obtain the target column fields;

[0132] The projection module is used to perform projection processing on the line data including the target column fields according to the projection rules, to obtain the projected line data;

[0133] The merging module is used to perform merging processing on the projected line data according to the file storage format, to obtain the target data;

[0134] The circular buffer is used to store the target data and transmit the data storage information to the message notification unit;

[0135] The message notification unit is used to generate notification information according to the data storage information and transmit the notification information to the database.

[0136] Furthermore, for ease of understanding, an example diagram of target data is provided in an embodiment of the present application, as Figure 8 shown. Among them, in the memory, the row data of the file to be queried is stored with a database page size of 8KB; the number of rows in the page is stored at a fixed position in the page, and starting from the fixed position in the page, the meta-information of the row data of the file to be queried is stored downward. The row data meta-information includes the row length and the offset of the row data in the page; starting from the bottom of the page upward, the row data is stored; each row data contains several column fields.

[0137] Furthermore, for ease of understanding, an example diagram of obtaining target data in a preset accelerator is provided in an embodiment of the present application, as Figure 9 shown. Among them, after parsing, filtering, and projection calculation of each row data 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 file storage format. The target data is submitted to the circular buffer and the database is notified to read it. For the database, the bitstream of the target data read from the circular buffer is regarded as a database file, and the row data contained in each target data in the database file meets the filtering conditions.

[0138] By using the parallel computing ability of the accelerator to perform filtering, projection, and merging processing on the data, the efficiency of data processing can be significantly improved, especially for query and processing tasks of large-scale data. According to the target filtering conditions and projection rules, using the parallel computing units in dedicated hardware (such as: the preset accelerator) and using the method of parallel computing with multiple pages, the target data that meets the query conditions can be screened out more quickly, reducing unnecessary data transmission and processing. According to the file storage format, data parsing and merging processing are performed to ensure that the format of the target data is consistent with the storage requirements of the database, improving the compatibility and availability of the data.

[0139] In an implementable manner of the embodiment of the present disclosure, when extracting the target data in the preset accelerator to the database, the following methods can also be adopted but are not limited to: based on the soft link in the target-oriented link, perform sequential reading processing on 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, perform sequential reading processing on 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, perform sequential reading processing on the target data in the preset accelerator and store the read target data.

[0140] In the embodiment of the present application, the database can directly read the target data through the link pointing to the preset accelerator in the redirect link, which can achieve efficient and stable data interaction between the database and the accelerator.

[0141] In an implementable manner of the embodiments of the present disclosure, after the query ends, a reset process is required. Therefore, after extracting the target data in the preset accelerator to the database through the target-oriented link, the following method can also be adopted: perform a deletion process on the target-oriented link.

[0142] Further, related to the above embodiments, the deletion process of the target-oriented link can also be implemented by, but not limited to, the following methods: rename the temporary file to be queried to the file to be queried, and delete the soft link and the target mapping table; or, delete the target extended attribute in the added file to be queried, and delete the first file handle and the second file handle; or, delete the intermediate layer in the preset operating system.

[0143] Through targeted deletion processing, ensure that the database file system is completely restored to the state before acceleration, and avoid the residual redirection configuration from affecting the correctness of subsequent queries. Release system resources such as soft links, file handles, and intermediate layer processes in a timely manner, reduce memory overhead, and ensure the stability of the long-term operation of the database. Decouple the deletion logic from the creation method, support unified management of multiple redirection schemes, and facilitate subsequent system upgrades or expansion of other acceleration strategies.

[0144] In summary, the embodiments of the present application can achieve the following technical effects:

[0145] 1. A database hardware acceleration method, an electronic device, and a storage medium of the present application obtain the parameter information of the target function in the query process, that is, the query parameter information, by injecting instructions into the target query function in the database, and send the query parameter information to the accelerator. The accelerator processes 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, read the target data that meets the target filtering conditions from the accelerator, and achieve the technical effect of hardware acceleration without modifying the database source code. Therefore, it can solve the technical problems in the related art that the development difficulty of the database integrated hardware acceleration function is large and it needs to be separately maintained for different versions of the database, and achieve the technical effect of hardware acceleration of the database without modifying the database source code.

[0146] 2. The present application uses the eBPF technology to achieve non-intrusive expansion of the existing database system, and can add hardware acceleration support without modifying the database code, avoiding in-depth customization or secondary development of the database kernel, and reducing the implementation cost and complexity.

[0147] 3. For different versions of the database in this application, the same set of eBPF loader and instructions can be used, eliminating the need for separate code development for each version, recompiling, deploying, and running, thus reducing the code development cost and the subsequent maintenance and operation cost.

[0148] 4. This application provides multiple file redirection methods to adapt to different scenarios and system requirements.

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

[0150] 6. This application supports multiple database systems and hardware platforms, has good scalability and compatibility, and is convenient for promotion and application in different environments.

[0151] 7. The eBPF technology in this application can inject instructions into all database processes. At the same time, it can query the process identifier (PID) through the process ID number to distinguish different user processes, and can achieve hardware acceleration for specified user processes.

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

[0153] The embodiments of this application also provide a database hardware acceleration device. Figure 10 As shown in the structural schematic diagram of a database hardware acceleration device provided by this application, Figure 10 it includes:

[0154] An injection unit 1001, configured to inject a first preset instruction into the target query function of the database in response to a data query instruction;

[0155] An acquisition unit 1002, configured to acquire query parameter information of the target query function based on the first preset instruction;

[0156] A configuration unit 1003, configured to re-encode the query parameter information and then configure it into a preset accelerator;

[0157] An orientation unit 1004, 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 redirection link, where the target redirection 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;

[0158] The first extraction unit 1005 is configured to extract the file to be queried in the memory to the accelerator based on the target directed link;

[0159] The filtering unit 1006 is configured to filter the file to be queried in the accelerator according to the target filtering condition in the query parameter information to obtain target data, and the file to be queried is determined in the memory through the target mapping table in the target directed link;

[0160] The second extraction unit 1007 is configured to extract the target data in the preset accelerator to the database through the target directed link.

[0161] In an embodiment of the present application, the injection unit 1001 is further configured to:

[0162] Insert a first entry code instruction and a first end code instruction into the filtering condition generation function in the target query function, where the first entry code instruction is at least used to obtain the target filtering condition, and the first end code instruction is used to set the return value of the filtering condition generation function to a null value;

[0163] Insert a second entry code instruction and a second end code instruction into the projection rule generation function in the target query function, where 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;

[0164] Insert a third entry code instruction into the scanning function in the target query function, where 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.

[0165] In an embodiment of the present application, the acquisition unit 1002 is further configured to:

[0166] Obtain the query process identifier corresponding to each query process executed by the target query function, and perform a matching process in the preset target identifier information according to multiple query process identifiers to determine multiple target process identifiers, where the target process identifier is the query process identifier corresponding to the target query process in the query process, the target query process is the query process to be accelerated, and the preset target identifier information includes the identifier information corresponding to the target query process;

[0167] Obtain the first parameter information corresponding to each query process based on the first preset instruction, and classify the first parameter information according to the target process identifier to obtain the classified first parameter information corresponding to each of the multiple target query processes;

[0168] When it is determined that the first parameter information after any classification satisfies the preset parameter condition, the first parameter information after classification that satisfies the preset parameter condition is determined as the query parameter information.

[0169] In an embodiment of the present application, the orientation unit 1004 is further configured to:

[0170] Determine the file to be queried in the memory according to the address of the file to be queried;

[0171] Create a soft link pointing to the preset accelerator according to the file to be queried to obtain the target orientation link; or,

[0172] Perform target extended attribute addition processing on the file to be queried, and generate a file handle pointing to the preset accelerator according to the file to be queried after the addition to obtain the target orientation link, where the target extended attribute at least includes a node file pointing to the preset accelerator; or,

[0173] Add an intermediate layer between the operation layer and the application layer of the preset operating system, and create a target orientation link through the intermediate layer, where the preset operating system is the system that executes the database hardware acceleration method.

[0174] In an embodiment of the present application, the orientation unit 1004 is further configured to:

[0175] Create a soft link pointing to the preset accelerator according to the file to be queried;

[0176] 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, where the target mapping table is used to determine the location 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;

[0177] Perform link determination processing according to the target mapping table and the soft link to obtain the target orientation link.

[0178] In an embodiment of the present application, the orientation unit 1004 is further configured to:

[0179] Perform target extended attribute addition processing on the file to be queried to obtain the file to be queried after the addition;

[0180] Perform handle generation processing according to the file to be queried after the addition to obtain a first file handle and a second file handle, where 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;

[0181] Determine a target mapping table of a file to be queried in a memory according to a first file handle, where 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;

[0182] Perform link determination processing according to a second file handle and the target mapping table to obtain a target directed link.

[0183] In an embodiment of the present application, the orientation unit 1004 is further configured to:

[0184] Add a processing in an intermediate layer between an operation layer and an application layer of a preset operating system to obtain an intermediate layer, where the preset operating system is a system for executing a database hardware acceleration method;

[0185] Generate a database directory according to a file in the memory, and mount the database directory to the intermediate layer;

[0186] In the intermediate layer, generate a mapping list corresponding to the file to be queried according to the file to be queried and the database directory, and determine a target mapping table according to the mapping list;

[0187] In the intermediate layer, create a third file handle pointing to a preset accelerator, and perform link determination processing according to the third file handle and the target mapping table to obtain a target directed link.

[0188] In an embodiment of the present application, the first extraction unit 1005 is further configured to:

[0189] Perform a file acquisition process in the memory according to the target mapping table in the target directed link to obtain the file to be queried;

[0190] Extract the file to be queried into the accelerator.

[0191] In an embodiment of the present application, the filtering unit 1006 is further configured to:

[0192] Parse the field positions of the column fields corresponding to the respective multiple line data from the multiple line data of the file to be queried according to the file storage format;

[0193] Based on the field positions, determine the column fields that meet the target filtering condition among the column fields corresponding to the respective multiple line data according to the target filtering condition to obtain target column fields;

[0194] Perform projection processing on the line data including the target column fields according to the projection rule to obtain projected line data;

[0195] Perform merging processing on the projected line data according to the file storage format to obtain target data;

[0196] Store the target data in a circular buffer of a preset accelerator.

[0197] In one embodiment of the present application, the second extraction unit 1007 is further configured to:

[0198] Based on the soft link in the target-oriented link, perform sequential reading processing on the target data in the preset accelerator, and perform storage processing on the read target data; or,

[0199] Based on the second file handle in the target-oriented link, perform sequential reading processing on the target data in the preset accelerator, and perform storage processing on the read target data; or,

[0200] Based on the third file handle in the target-oriented link, perform sequential reading processing on the target data in the preset accelerator, and perform storage processing on the read target data.

[0201] In one embodiment of the present application, as Figure 11 shown, the database hardware acceleration device further includes:

[0202] A deletion unit 1008, configured to perform deletion processing on the target-oriented link.

[0203] In one embodiment of the present application, the deletion unit 1008 is further configured to:

[0204] Rename the temporary file to be queried to the file to be queried, and delete the soft link and the target mapping table; or,

[0205] Delete the target extended attribute in the added file to be queried, and delete the first file handle and the second file handle; or,

[0206] Delete the intermediate layer in the preset operating system.

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

[0208] An embodiment of the present application further provides an electronic device, including a memory and a processor. 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 embodiments of the database hardware acceleration method.

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

[0210] In an exemplary embodiment, the above computer-readable storage medium may include, but is not limited to: various media such as USB flash drives, read-only memory (ROM for short), random access memory (RAM for short), external hard drives, magnetic disks, or optical discs that can store computer programs.

[0211] The embodiments of the present application also provide a computer program product. The above computer program product includes a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above embodiments of the database hardware acceleration method.

[0212] The embodiments of the present application also provide another computer program product, including a non-volatile computer-readable storage medium. The non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the steps in any of the above embodiments of the database hardware acceleration method.

[0213] Those skilled in the art can further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Skilled professionals can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0214] The above has introduced in detail a database hardware acceleration method, an electronic device, and a storage medium provided by the present application. Specific examples are used herein to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application. It should be noted that for those of ordinary skill in the art in the technical field, without departing from the principle of the present application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope 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

  • Volatile database caching in database accelerator

    CN117043763A

  • Logic design system for controller hardware acceleration

    CN119806644A