Data query method, electronic device, and computer-readable storage medium

By using bitmap index parallel comparison technology and SIMD instruction set for parallel AND and equality operations, the problem of slow query speed for large data tables is solved, and fast data query is achieved.

CN116860798BActive Publication Date: 2026-01-13XFUSION DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310736686.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-20
Publication Date
2026-01-13
Estimated Expiration
2043-06-20

AI Technical Summary

Technical Problem

When a data table has many attributes and many tuples, the data query speed is slow, resulting in a long waiting time for users.

Method used

We employ bitmap index parallel comparison technology and utilize the SIMD instruction set to perform parallel AND and equality operations, thereby improving data query efficiency.

Benefits of technology

By comparing the bits of the bitmap index and the tuple in parallel, it is possible to quickly determine whether the tuple satisfies the query terms, which significantly improves the efficiency of data query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116860798B_ABST
    Figure CN116860798B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data query method, an electronic device and a computer readable storage medium. The electronic device stores a first data table including a first tuple and a first bitmap index corresponding to the first tuple. The first tuple includes one or more queryable attribute values. The first bitmap index includes a plurality of bits arranged in sequence. The method includes receiving a query request for the first data table. The query request includes a query item including an attribute value to be queried. A second bitmap index corresponding to the query item is generated based on the attribute value to be queried. The second bitmap index corresponding to the query item and values of the plurality of bits at the same positions in the first bitmap index corresponding to the first tuple are compared simultaneously to determine whether the first tuple satisfies the query item. Embodiments of the present application can improve the efficiency of data query.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of databases, and more particularly to a data query method, an electronic device, and a computer-readable storage medium. Background Technology

[0002] With the rapid development of network and communication technologies, massive amounts of data are impacting various industries at an unprecedented growth rate. To effectively manage and maintain this data, users typically use databases for data storage. Furthermore, they usually create indexes for the data tables in the database to facilitate subsequent data retrieval.

[0003] However, when the data table has many attributes (such as 20 attributes) and stores a large number of tuples (such as 1 million tuples), the data query speed is slow, resulting in a long waiting time for users. Summary of the Invention

[0004] This application discloses a data query method, an electronic device, and a computer-readable storage medium, which can improve data query efficiency.

[0005] The first aspect discloses a data query method that can be applied to electronic devices, modules within electronic devices (e.g., chips, processors, etc.), and logic modules or software (such as databases) capable of implementing all or part of the functions of an electronic device. The electronic device stores a first data table, which includes a first tuple. The electronic device also stores a first-bit graph index corresponding to the first tuple. The first tuple includes one or more queryable attribute values. The first-bit graph index includes a plurality of sequentially arranged bits, the values ​​of which characterize the queryable attribute values ​​of the first tuple. The following description uses an application to an electronic device as an example. The data query method may include: receiving a query request for the first data table, the query request including a query item, the query item including an attribute value to be queried, the query request being used to request a query for tuples that satisfy the query item; generating a second bitmap index corresponding to the query item based on the attribute value to be queried; the value of the bit in the second bitmap index corresponding to the query item being used to represent the attribute value to be queried; and simultaneously comparing the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of the first bitmap index corresponding to the first tuple to determine whether the first tuple satisfies the query item.

[0006] In this embodiment of the application, when performing data query, the values ​​of multiple bits at the same position in the bitmap index corresponding to the query item and the bitmap index corresponding to the first tuple can be compared simultaneously. This can improve the comparison efficiency of the bitmap index, thereby more quickly determining whether the first tuple satisfies the query item, and thus improving the data query efficiency.

[0007] As one possible implementation, the queryable attribute value has a first hash value, which includes hash values ​​calculated by the queryable attribute value using multiple hash functions.

[0008] In this embodiment of the application, when generating a bitmap index corresponding to a tuple, multiple hash values ​​can be calculated using multiple hash functions for a single queryable attribute value. This reduces the probability that multiple hash values ​​corresponding to different values ​​of the same attribute will be identical, thus lowering the probability of false lookups.

[0009] As one possible implementation, comparing the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item and the first bitmap index corresponding to the first tuple simultaneously includes: performing a parallel AND operation on the values ​​of multiple bits included in the first bitmap index corresponding to the first tuple and the values ​​of multiple bits at the same position included in the second bitmap index corresponding to the query item to obtain the operation result, and determining whether the first tuple satisfies the query item based on the AND operation result.

[0010] In this embodiment, when comparing the values ​​of multiple bits at the same position in the bitmap index corresponding to the query item and the bitmap index corresponding to the first tuple simultaneously, a parallel AND operation can be performed on the values ​​of the multiple bits at the same position in the bitmap index corresponding to the query item and the bitmap index corresponding to the first tuple. This allows for a faster AND operation result, thereby improving the overall efficiency of data querying. Specifically, during the parallel AND operation, the bitmap index corresponding to the query item and the bitmap index corresponding to the first tuple can be loaded into registers respectively, and then the parallel AND operation is performed based on SIMD instructions. This allows the AND operation result to be obtained with a single instruction.

[0011] In this context, each bit of the first bitmap index corresponds to a hash value, and the value of each bit indicates whether the corresponding hash value exists. The first bitmap index is calculated using a hash function based on the queryable attribute value in the first tuple, and the second bitmap index corresponding to the query item is calculated using the same hash function based on the attribute value with the query.

[0012] As one possible implementation, determining whether the first tuple satisfies the query term based on the AND operation result includes: simultaneously performing parallel equality operations on the values ​​of multiple bits at the same position included in the AND operation result and the second bitmap index corresponding to the query term, to obtain an equality operation result, which is used to indicate whether the first tuple satisfies the query term.

[0013] In this embodiment, after obtaining the AND operation result of the bitmap index corresponding to the first tuple and the bitmap index corresponding to the query item, the AND operation result can be simultaneously performed with the values ​​of multiple bits at the same position in the bitmap index corresponding to the query item in parallel. This allows for a rapid acquisition of the equality operation result, thereby improving the overall efficiency of data querying. Specifically, during the parallel equality operation, the bitmap index corresponding to the query item and the AND operation result can be loaded into registers respectively, and then the parallel equality operation can be performed based on SIMD instructions. This allows the equality operation result to be obtained with a single instruction.

[0014] In one possible implementation, the first tuple includes multiple tuples. The simultaneous comparison of the second bitmap index corresponding to the query item with the values ​​of multiple bits at the same position in the first bitmap index corresponding to the first tuple includes: sequentially loading the bitmap indices corresponding to N tuples from the multiple tuples into the storage unit of the first register of the electronic device, where N is an integer greater than 1; copying the second bitmap index corresponding to the query item N times and sequentially loading it into the storage unit of the second register of the electronic device, where the first register and the second register include multiple storage units, each storage unit storing the value of one bit; performing parallel AND operations on the data in the first register and the second register to obtain the AND operation result; and determining whether the N tuples satisfy the query item based on the AND operation result.

[0015] In this embodiment, the bitmap indexes corresponding to multiple tuples can be loaded into the first register, and the bitmap indexes corresponding to the query item can be copied multiple times and loaded into the second register. Then, the data in the first register and the second register can be ANDed in parallel, such as by performing the AND operation in parallel on the data in the first register and the second register based on SIMD instructions. In this way, the AND operation results corresponding to multiple tuples can be obtained at one time, thereby improving the efficiency of data query.

[0016] As one possible implementation, the electronic device caches historical query requests and query results corresponding to those historical query requests. The method further includes: if the query request is the same as the historical query request, obtaining the query result corresponding to the historical query request; the simultaneous comparison of the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item and the first bitmap index corresponding to the first tuple includes: if the query request is different from the historical query request, simultaneously comparing the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item and the first bitmap index corresponding to the first tuple.

[0017] In this embodiment, after obtaining the query result corresponding to a query request, the query request and the query result corresponding to the query request can be cached in memory. In this way, when a new query request is received later, it can be first determined whether the query request is the same as the historical query request. If they are the same, the query result corresponding to the query request can be directly retrieved from memory without comparing the bitmap index corresponding to the query item in the query request with the bitmap index corresponding to each tuple in the first data table. This can shorten the query time and improve the query efficiency.

[0018] In one possible implementation, the first tuple includes multiple tuples, and the method further includes: sequentially loading the first attribute values ​​of M tuples from the multiple tuples into the storage unit of a third register, where the first attribute value is a queryable attribute value in the tuple, and M is an integer greater than 1; copying the calculation parameters in the first hash function corresponding to the first attribute value multiple times and sequentially loading them into the storage unit of a fourth register, where the first hash function is the hash function corresponding to the first attribute value, and the third register and the fourth register include multiple storage units, each storage unit being used to store the value of one bit; performing a first operation in parallel on the data in the third register and the fourth register to obtain a first operation result; the first operation result includes the result of performing a first operation on the first attribute values ​​of the M tuples respectively with the calculation parameters in the first hash function.

[0019] In this embodiment, since the same attribute value of different tuples uses the same hash function, a certain common attribute value (such as the first attribute value) of multiple tuples can be loaded into the third register, and the calculation parameters of the hash function can be copied multiple times and loaded into the fourth register. Then, the data in the third register and the fourth register are subjected to the first operation in parallel. In this way, the hash value corresponding to the first attribute value of multiple tuples can be calculated more quickly, thereby obtaining the bitmap index corresponding to multiple tuples more quickly, and thus improving the creation efficiency of the Bloom index corresponding to the first data table.

[0020] As one possible implementation, the processor of the electronic device supports any of the following instruction sets: Multimedia Extended Instruction Set, Single Instruction Multiple Data Extended Instruction Set, and Advanced Vector Extended Instruction Set.

[0021] In this embodiment, it can be implemented using any instruction set that supports SIMD instructions (such as the Multimedia Extension Instruction Set, Single Instruction Multiple Data Stream Extension Instruction Set, Advanced Vector Extension Instruction Set, etc.), which provides a relatively flexible implementation method.

[0022] The second aspect discloses an electronic device including a processor and a memory, wherein the processor calls a computer program stored in the memory to implement the data query method provided in the first aspect and any possible implementation thereof.

[0023] The third aspect discloses a computer-readable storage medium storing a computer program or computer instructions, which, when executed, implements the data query methods disclosed in the above aspects.

[0024] The fourth aspect discloses a chip including a processor for executing computer programs or computer instructions stored in a memory, which, when executed, cause the chip to perform the data query methods disclosed in the above aspects.

[0025] As one possible implementation, the memory is located outside the chip.

[0026] The fifth aspect discloses a computer program product comprising computer program code, which, when executed, causes the data query methods disclosed in the above aspects to be performed.

[0027] It should be understood that the implementation and beneficial effects of the above-mentioned aspects or any possible implementation methods of this application can be referred to each other. Attached Figure Description

[0028] The accompanying drawings are provided to more clearly illustrate the technical solutions of the embodiments of this application. The drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is a schematic diagram of a bitmap index comparison disclosed in an embodiment of this application;

[0030] Figure 2 This is a schematic diagram of the software structure of an electronic device disclosed in an embodiment of this application;

[0031] Figure 3 This is a schematic diagram of a data query scenario disclosed in an embodiment of this application;

[0032] Figure 4 This is a flowchart illustrating a Bloom index creation method disclosed in an embodiment of this application;

[0033] Figure 5 This is a schematic diagram of a parallel hash value computation method disclosed in an embodiment of this application;

[0034] Figure 6 This is a schematic diagram of another parallel hash value computation disclosed in an embodiment of this application;

[0035] Figure 7 This is a flowchart illustrating a data query method disclosed in an embodiment of this application;

[0036] Figure 8 This is a schematic diagram of another bitmap index comparison disclosed in an embodiment of this application;

[0037] Figure 9 This is a schematic diagram of another bitmap index comparison disclosed in the embodiments of this application;

[0038] Figure 10 This is a flowchart illustrating another data query method disclosed in an embodiment of this application;

[0039] Figure 11 This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. Detailed Implementation

[0040] This application discloses a data query method, an electronic device, and a computer-readable storage medium, which can improve data query efficiency. The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0041] To better understand the embodiments of this application, the relevant terms and technologies of the embodiments of this application will be described below.

[0042] A hash algorithm (function), also known as a hashing algorithm, can transform an input of arbitrary length into an output of fixed length. This output value can be called a hash value. For example, a hash function can be hash(key) = key % p, where key can be the input value, % is the modulo operation, and p is the modulo.

[0043] A Bloom filter can encode and compress a dataset into a smaller storage space, and can also query whether an element exists in the dataset. Specifically, for a dataset, a Bloom filter can encode and compress it into an m-bit vector based on a hash function. Initially, all bits of this m-bit vector can be 0. For a dataset S, assuming S contains three elements x1, x2, and x3, each element can have its hash value calculated using three independent hash functions. Then, based on the three calculated hash values, three bits can be selected from the m-bit vector and set to 1. The hash value generated by each of the three hash functions can be in the range [0, m-1]. For example, if the three calculated hash values ​​are 0, 2, and 5, then the 0th, 2nd, and 5th bits of the m-bit vector can be set to 1, such as 101001000... After calculating hash values ​​based on all elements in set S, and setting specific bits in an m-bit vector to 1 based on the calculated hash values, we obtain the encoding vector corresponding to set S, which is an m-bit vector containing 0s and 1s. Then, to check if an element xn exists in set S, we can calculate three hash values ​​for xn using the same three hash functions, resulting in an m-bit encoding vector for xn. This encoding vector may have three bits set to 1. We can then check if the corresponding three bits in the encoding vector corresponding to set S are all 1. If all three are 1, set S is considered to include xn; otherwise, set S does not include xn. It should be understood that duplicate hash values ​​may exist among all hash values ​​calculated using multiple different hash functions for all elements in set S. Therefore, a bit in the encoding vector corresponding to set S may be set to 1 multiple times, but only the first time has an effect.

[0044] SIMD (Single Instruction Multiple Data) refers to a single instruction operating on multiple sets of data. It is primarily used to provide parallel data operations to improve computational efficiency. SIMD can "split" the bits of a register into multiple narrow-width elements (such as 8, 16, or 32 bits), each of which can be operated on as independent data. This allows multiple sets of data to be loaded into the register, enabling parallel computation of multiple sets of data. In other words, SIMD can perform parallel operations on multiple data streams through a single instruction (similar to vector computation), thus improving the execution efficiency of certain tasks. It should be noted that this type of instruction, which operates on multiple sets of data in a single instruction, is called a SIMD instruction.

[0045] Instruction sets supporting SIMD can include MMX (MultiMedia eXtensions), SSE (Streaming SIMD Extensions), and AVX (Advanced Vector Extensions). It should be understood that MMX, SSE, and AVX instruction sets evolved to meet specific needs, and they may differ in the number of instructions, instruction formats, etc. Furthermore, the corresponding CPU (central processing unit) architecture, the number of registers in the CPU, and the register bit widths may also differ.

[0046] A database cluster is typically a database system composed of multiple machines (such as servers). One or more databases can be created on a database cluster. A single server in a database cluster, or the smallest computing unit within a server, can be called a node.

[0047] Database clusters can include centralized database clusters, distributed database clusters, etc. A centralized database cluster can include one master node (master node) and multiple slave nodes (slave nodes), and the master and slave nodes can store the same data. A distributed database cluster can also include a master node and multiple slave nodes. Each slave node can store a shard of data, and the data shards stored on multiple nodes can be combined to form a complete dataset. The master node can also be called the coordinating node or management node, and the slave nodes can be called data nodes. The master node in a database cluster can manage and monitor each slave node. For example, the master node can issue data operation commands, such as data query commands, to each slave node, instructing it to perform data queries.

[0048] A database stores data in tables, each containing multiple columns and rows. Each row (each record in the database) is called a tuple, and each column can represent an attribute. In other words, a tuple is the smallest unit of storage for a row of data, and it can contain the values ​​of all the attributes (fields) of a row.

[0049] Database functions include adding, modifying, querying, and deleting data. Querying data is perhaps one of the most frequently used functions. Therefore, indexes are typically created for database tables in advance to improve query efficiency. Indexes can include B-tree indexes and Bloom indexes, with Bloom indexes being more widely used due to their advantages in space efficiency and query time. A Bloom index is essentially created based on the principle of a Bloom filter. For each column in a table that needs an index (hereinafter referred to as the index column), a corresponding hash function can be set. Then, for each row of data corresponding to the index column, the corresponding hash function can be used to calculate the hash value, and then the corresponding m-bit vector is obtained based on the calculated hash value. Each row of data can include a corresponding encoded vector, which can also be called a bitmap index.

[0050] For example, suppose data table 1 includes 100,000 rows and 5 columns, which can be col-1, col-2, col-3, col-4, and col-5. Now, we need to create Bloom indexes on col-1, col-2, and col-3. col-1 can use two hash functions, hash function 1 and hash function 2. col-2 can use three hash functions, hash functions 3-5, and col-3 can use three hash functions, hash functions 6-8. Each hash function can generate hash values ​​within the range [0, m-1]. The bitmap index corresponding to each row of data can be an m-bit vector. For example, tuple 1 in data table 1 can be x1, y1, z1, w1, and s1. Using hash function 1 and hash function 2, we can calculate two hash values ​​for x1; using hash functions 3-5, we can calculate three hash values ​​for y1; and using hash functions 6-8, we can calculate three hash values ​​for z1. Furthermore, the bitmap index corresponding to tuple 1 can be obtained based on these 8 hash values. If all 8 hash values ​​are different, the bitmap index corresponding to tuple 1 can include 8 bits set to 1. Similarly, the corresponding bitmap indexes for other tuples in data table 1 can be calculated in the same way. It should be understood that when calculating the bitmap index corresponding to a tuple, it is necessary to perform hash calculations on the values ​​of different index columns in turn using the hash function corresponding to each index column.

[0051] It should be noted that during the creation of a Bloom index for Data Table 1, a corresponding Bloom index tuple can be generated for each tuple in Data Table 1. The Bloom index tuple corresponding to a tuple in Data Table 1 can include a head pointer to that tuple and a signature corresponding to that tuple. This signature is also a bitmap index generated based on the values ​​of the indexed columns in that tuple. The head pointer of a tuple indicates the storage address of that tuple and can be used to retrieve the data corresponding to that tuple. It should be noted that, in this embodiment, the Bloom index of a tuple is also a bitmap index generated based on the values ​​of the indexed columns in that tuple.

[0052] After creating a Bloom index, if you need to query data based on the created Bloom index, you can calculate the bitmap index corresponding to the query item using the same hash function. Then, you can compare the bitmap index corresponding to the query item with the bitmap index corresponding to each tuple in the data table. If all the bits set to 1 in the bitmap index corresponding to the query item are also set to 1 in the bitmap index corresponding to a tuple, it can be determined that the tuple satisfies (matches) the query item and can be used as one of the query results. Otherwise, it can be determined that the tuple does not satisfy the query item. For example, assuming the query items are: col-1 = x2, col-2 = y2, you can calculate the two hash values ​​corresponding to x2 using hash function 1 and hash function 2, and calculate the three hash values ​​corresponding to y2 using hash functions 3-5. Based on these five hash values, you can obtain the bitmap index corresponding to the query item. If these five hash values ​​are all different, then the m bits can include five bits set to 1. Next, the bitmap index corresponding to the query term can be compared with the bitmap index corresponding to each tuple in Table 1. If all 5 bits of the bitmap index corresponding to a tuple are also set to 1 in the bitmap index corresponding to the query term, then the tuple satisfies the query term and can be included as one of the query results. Otherwise, the tuple does not satisfy the query term. It should be understood that since the query term may not include all indexed columns (e.g., the example above only includes col-1 and col-2), the number of bits set to 1 in the bitmap index corresponding to the query term can be less than the number of bits set to 1 in the bitmap index corresponding to a tuple.

[0053] The bitmap index corresponding to a query term can also be called a BloomScanOpaque. It should be understood that when comparing the bitmap index corresponding to a query term with the bitmap index corresponding to a tuple in the data table, a bitwise AND operation is performed between the bitmap index of the query term and the bitmap index of the tuple. Then, the result is compared with the mask. If they are equal, the tuple satisfies the query term; otherwise, it does not. The mask is the same as the bitmap index corresponding to the query term.

[0054] In related technologies, when performing a bitmap AND operation between the bitmap index corresponding to a query item and the bitmap index corresponding to a tuple in a data table, the AND operation is performed bit by bit. That is, the CPU performs an AND (&) operation between one bit in the bitmap index corresponding to the query item and one bit in the bitmap index corresponding to the tuple each time, requiring a total of m AND operations to obtain the final AND result. For example, as shown... Figure 1 As shown, when performing a bitmap AND operation between the bitmap index corresponding to the query item and the bitmap index corresponding to tuple 1 in the data table, the CPU can first perform 0&0, then 1&0, 0&0, 0&0, etc., until the final AND result is obtained after m AND operations. Next, the AND result needs to be compared with the mask. During this comparison, each bit needs to be compared; that is, the CPU will perform an equality operation between one bit of the AND result and one bit of the mask each time. If every bit of the AND result and the mask are equal, the tuple satisfies the query item, and the data corresponding to the tuple can be retrieved based on the tuple's head pointer and returned as one of the query results. If the AND result and the mask have at least one unequal bit, the tuple does not satisfy the query item.

[0055] The above processing flow requires bitwise AND operations and bitwise equality operations. Therefore, comparing the bitmap index corresponding to a query item with the bitmap index corresponding to a tuple requires a maximum of 2m operations. In other words, the number of operations is related to m; the larger m is, the more operations are required, and the longer the query time.

[0056] To improve the query efficiency of Bloom indexes, this embodiment employs SIMD technology, which means using a SIMD-enabled instruction set (such as the AVX instruction set) for parallel data computation. This allows for parallel AND operations between multiple bits in the bitmap index corresponding to the query item and multiple bits in the bitmap index corresponding to a tuple in the data table, as well as parallel equality operations between multiple bits in the AND result and multiple bits in the mask. This improves the comparison speed between the bitmap index corresponding to the query item and the bitmap index corresponding to a tuple in the data table, enabling faster determination of whether a tuple in the data table satisfies the query item, thereby improving query efficiency. Simultaneously, SIMD technology can also be used to create Bloom indexes, further improving their creation efficiency.

[0057] To better understand the embodiments of this application, the system architecture of the embodiments of this application will be described below.

[0058] Please see Figure 2 , Figure 2 This is a schematic diagram of the software structure of an electronic device disclosed in an embodiment of this application. The electronic device 200 can be a terminal device such as a laptop or desktop computer, a server, etc., and is not limited thereto in this embodiment. The electronic device 200 may include a database 201.

[0059] Database 201 may include a query cache module 2011, a parser 2012, an optimizer 2013, an executor 2014, and a storage engine 2015. The query cache module 2011 is used to cache the query results corresponding to the query requests submitted by the client to database 201 in memory. Then, for a given query request, it can first be determined whether the data can be found in the cached memory; that is, whether the queried data is located in memory. If it is, the corresponding data can be returned directly. Therefore, the query cache module 2011 can improve the query efficiency of the database.

[0060] Parser 2012 can perform semantic and syntactic analysis on client requests (such as query requests). For example, it can parse client requests (such as query requests), generate corresponding parse trees, and perform syntax validation according to relevant grammar rules to confirm whether they conform to specifications. It's understandable that client requests are generally referred to as query statements, such as SQL (Structured Query Language) statements.

[0061] The optimizer 2013 can be used to optimize client requests, transforming them into execution plans. The optimizer can derive the optimal execution plan based on a series of algorithms to improve execution efficiency (such as data query efficiency). In one possible implementation, if multiple indexes (such as B-tree indexes, Bloom indexes, etc.) are created on a table, the optimizer 2013 can select the most suitable index for the query based on the client's query request.

[0062] The executor 2014 can be used to execute the execution plan generated by the optimizer 2013, and can interact with the storage engine 2015 to interact with the underlying files.

[0063] Storage Engine 2015 is a core component of the database, primarily responsible for writing, deleting, querying, and modifying data. Storage Engine 2015 mainly interacts with underlying files, such as data files and log files stored on disk.

[0064] Understandably, a database client can communicate with a database (data interaction), such as through a network. Database clients can be desktop applications, web applications, command-line terminals, etc. Furthermore, users can use database clients to write, delete, query, and modify data.

[0065] In this embodiment, when the storage engine 2015 queries data, for queries on Bloom indexes, it can use a SIMD-supporting instruction set (such as the AVX instruction set) for parallel data computation. This allows for parallel AND operations between multiple bits in the bitmap index corresponding to the query item and multiple bits in the bitmap index corresponding to a tuple in the data table, and parallel equality operations between multiple bits in the AND result and multiple bits in the mask. This improves the comparison speed between the bitmap index corresponding to the query item and the bitmap index corresponding to a tuple in the data table, allowing for faster determination of whether a tuple in the data table satisfies the query item, thereby improving query efficiency.

[0066] It should be noted that the aforementioned electronic device 200 can be a node in a centralized database cluster, a node in a distributed database cluster, or other devices that include a database. Specifically, in a distributed database cluster, the master node or coordinating node can send query commands to the slave nodes, and each slave node, upon receiving the query command, can perform a query within its locally stored data.

[0067] It should be noted that, Figure 2 The software structure shown is merely illustrative and does not constitute a limitation thereof. In other embodiments of this application, Figure 2The software architecture shown may include more or fewer software modules than illustrated.

[0068] The following is combined Figure 3 The query process of this application embodiment is described by way of example.

[0069] Please see Figure 3 , Figure 3 This is a schematic diagram illustrating a data query scenario disclosed in an embodiment of this application. For example... Figure 3 As shown, client 300 can send a query request to database 201, such as `select * from data table 1 where A = a1 and B = b1`. This query request can be used to query all tuples in data table 1 where attribute A is a1 and attribute B is b1. After receiving the query request, database 201's query cache module 2011 can first determine whether the data cached in memory can be hit. If it is hit, the corresponding query result can be returned directly. If it is not hit, it can be parsed by parser 2012, and then optimized by optimizer 2013 to generate an execution plan, for example, selecting to query based on a Bloom index. Afterwards, executor 2014 can execute the execution plan generated by optimizer 2013, and can call the corresponding API (application programming interface) to perform the query. Then, storage engine 2015 responds to the corresponding API call and can perform the query based on the pre-generated Bloom index. In this embodiment, when performing a query based on a Bloom index, storage engine 2015 can use a SIMD-supporting instruction set (such as the AVX instruction set) for parallel data computation to improve query efficiency. Once the storage engine 2015 obtains the query results, it can return them to the executor 2014. The executor 2014 can then return the results to the client (300) or to the query cache module 2011. The query cache module 2011 can store the query results in memory for later use.

[0070] It should be understood that the client 300 can be a software program that can run on devices such as laptops, desktop computers, and servers, and is not limited thereto in this embodiment. For example, the client 300 can run on electronic device 200.

[0071] Based on the above system architecture, please refer to Figure 4 , Figure 4 This is a flowchart illustrating a Bloom index creation method disclosed in an embodiment of this application. Figure 4 As shown, the method for creating a Bloom index may include, but is not limited to, the following steps:

[0072] 401. The electronic device receives a Bloom index creation request for the first data table.

[0073] The first data table can be any table in the database. It can include multiple tuples and multiple columns, each corresponding to an attribute. A Bloom index creation request for the first data table can include the signature length (the number of bits corresponding to the bitmap index in the Bloom index tuple), the columns to be indexed, and the number of bits allocated to the signature for each index column. It should be understood that the attribute corresponding to the index column can be called a queryable attribute. Accordingly, each tuple can include one or more queryable attribute values.

[0074] For example, a Bloom index creation request can be: `CREATE Index index_Name ON tbl_NameUSING bloom(x,y,z) WITH(length=128,col1=2,col2=2,col3=4)`. Here, `index_Name` is the specified index name, `tbl_Name` can be the name of the data table for which the index needs to be created (here, the name of the first data table), `bloom` indicates the creation of a Bloom index, `x`, `y`, and `z` can be three attributes from the first data table, `length` indicates the signature length (here, 128 bits), and `col1`, `col2`, and `col3` indicate the number of bits occupied by `x`, `y`, and `z` in the signature, respectively. Attribute `x` can occupy 2 bits, meaning two hash functions can be used. Attribute `y` can also occupy 2 bits, using two hash functions. Attribute `z` can occupy 4 bits, using four hash functions. Each hash function can generate a hash value within the range [0, length-1].

[0075] It should be understood that using multiple hash functions for an attribute can reduce the probability of false queries. For example, suppose attribute x includes values ​​x1 and x2. Hash function 1 calculates the same hash value for x1 and x2. Hash function 2 calculates different hash values ​​for x1 and x2. Therefore, if only hash function 1 is used, false queries may occur because querying x = x1 or x = x2 will return all tuples of x = x1 or x = x2. However, if two hash functions are used, namely hash function 1 and hash function 2, the above situation will not occur. Querying x = x1 will return the tuple of x = x1, and querying x = x2 will return the tuple of x = x2.

[0076] 402. Electronic devices create a Bloom index for the first data table based on a Bloom index creation request using SIMD.

[0077] After receiving a Bloom index creation request for a first data table, the electronic device can create a Bloom index for the first data table based on the request. The creation of the Bloom index can be performed using SIMD instructions. For example, if the CPU of the electronic device supports the AVX instruction set, it can use the corresponding SIMD instructions in the AVX instruction set to perform parallel data processing, thereby accelerating the creation of the Bloom index.

[0078] Since each tuple in the first data table uses the same hash function on a certain index column, SIMD can be used for parallel computation of the same attribute in multiple tuples, allowing the hash values ​​of multiple tuples to be obtained with a single instruction. For example, the first data table can be shown in Table 1 below:

[0079] Table 1

[0080] x1 y1 z1 x2 y2 z2 x3 y3 z3 x4 y4 z4 …… …… ……

[0081] In Table 1 above, the first column can be the x attribute, the second column can be the y attribute, and the third column can be the z attribute. The first data table can include tuples 1-4. The x, y, and z attribute values ​​for tuple 1 are x1, y1, and z1, respectively; for tuple 2, the values ​​are x2, y2, and z2; for tuple 3, the values ​​are x3, y3, and z3; and for tuple 4, the values ​​are x4, y4, and z4. The two hash functions corresponding to the x attribute can be hash function 1 and hash function 2, the two hash functions corresponding to the y attribute can be hash function 3 and hash function 4, and the four hash functions corresponding to the z attribute can be hash functions 5-8. Specifically, hash function 1 can be key%p1, hash function 2 can be key%p2, hash function 3 can be key%p3, hash function 4 can be key%p4, hash function 5 can be key%p5, hash function 6 can be key%p6, hash function 7 can be key%p7, and hash function 8 can be key%p8. Based on this, if the electronic device includes a 128-bit wide CPU register, and the data types corresponding to x, y, z, and p1-p8 are all 4-byte integer variables, that is, 32-bit integer variables, the electronic device can use SIMD parallel computation to calculate x1, x2, x3, and x4 modulo p1, or it can use parallel computation to calculate y1, y2, y3, and y4 modulo p3, etc. It should be noted that, for ease of understanding, the first data table is presented in tabular form above, but the storage format of the first data table is not limited in this embodiment.

[0082] For example, please see Figure 5The electronic device can store x1 in bits 0-31 of register 1, x2 in bits 32-63, x3 in bits 64-95, and x4 in bits 96-127. Register 2 can store p1 in bits 0-31, 32-63, 64-95, and 96-127 respectively. Then, the electronic device can perform parallel calculations of x1%p1, x2%p1, x3%p1, and x4%p1 based on a single instruction, such as instruction A, and store the corresponding results in the corresponding positions in register 3. Instruction A can be used to instruct the 128 bits of registers 1 and 2 to be divided into 32-bit units, with each 32-bit unit being an independent element, and to perform modulo operations on the corresponding elements in registers 1 and 2. Therefore, when using SIMD technology, multiple sets of data stored in registers can be calculated in parallel based on a single instruction, improving computational efficiency.

[0083] It should be understood that the instruction set used by a CPU includes multiple instructions, each with different functions. For example, instruction A above can treat each 32-bit element in register 1 and register 2 as an independent element, and perform a modulo operation on the corresponding elements in register 1 and register 2. Instruction B can treat each 64-bit element in register 1 and register 2 as an independent element, and perform a modulo operation on the corresponding elements in register 1 and register 2. It should be noted that the registers and parallel operations described above are merely illustrative and do not constitute a limitation. Different CPUs may include different registers; for example, they may include registers with widths of 256, 512, or 1024 bits. These registers can perform parallel computations on more data; for example, a 256-bit register can perform parallel computations on eight 32-bit integer variables.

[0084] Generally, when performing parallel computations on multiple sets of data using SIMD, the computations are usually of the same type, such as AND or addition operations between the multiple sets of data. Therefore, if all the hash functions used to generate the bitmap index corresponding to a tuple contain operations of the same type, SIMD can be used for parallel computation. For example, hash functions 1-8 used above all involve modulo operations, meaning they are all of the same type. In this case, for a single tuple, the hash values ​​corresponding to hash functions 1-8 can be computed in parallel using SIMD. For example, please refer to [link to example]. Figure 6The electronic device can store x1 in bits 0-31 and 32-63 of register 1, and y1 in bits 64-95 and 96-127. Bits 0-31 of register 2 can store p1, bits 32-63 can store p2, bits 64-95 can store p3, and bits 96-127 can store p4. Then, the electronic device can calculate x1%p1, x1%p2, y1%p3, and y1%p4 in parallel based on a single instruction, such as instruction A, and store the corresponding results in the corresponding positions in register 3. Similarly, the electronic device can calculate the four hash values ​​of z1 using hash functions 5-8 in the same way, and the corresponding bitmap indices can be calculated for other tuples in the first data table in the same way.

[0085] In this embodiment of the application, the created Bloom index can be stored on the disk of the electronic device so that it can be directly read and used when querying data later.

[0086] In the above process, when creating a Bloom index, parallel computation can be performed based on SIMD, and multiple hash values ​​can be calculated with a single instruction, thereby improving the efficiency of Bloom index creation.

[0087] Based on the above system architecture, please refer to Figure 7 , Figure 7 This is a flowchart illustrating a data query method disclosed in an embodiment of this application. Figure 7 As shown, this data query method may include, but is not limited to, the following steps:

[0088] 701. The electronic device receives a query request for the first data table.

[0089] Specifically, when a user needs to query data from the first data table in the database, the user can send a query request for the first data table to the electronic device through a client. The query request for the first data table can include specific query conditions, the attributes to be queried, and the identifier of the first data table (such as the name of the first data table).

[0090] For example, a query request could be `select * from tbl_Name where x = x2 and y = y2`. Here, the `*` indicates that the query results should include all attributes, `tbl_Name` can be the name of the table to be queried (here, it can be the name of the first table), and `where x = x1 and y = y1` indicates the query conditions or query terms, meaning that attribute x must be x1 and attribute y must be y1.

[0091] 702. The electronic device determines whether the query request for the first data table hits the data cached in memory. If it hits, step 703 can be executed; if it misses, step 704 can be executed.

[0092] After receiving a query request for the first data table, the electronic device can first determine whether the query request hits the data cached in memory. If it hits, the data in memory can be directly retrieved as the query result, and step 703 can be executed. If it misses, step 704 can be executed.

[0093] Specifically, in this embodiment, after an electronic device receives a query request and obtains the corresponding query result, it can store the query request and its corresponding query result in memory. This allows it to determine whether a new query request is the same as a historical query request, i.e., whether the same query request has been received previously. For example, after receiving query request 1 and obtaining the corresponding query result, the electronic device can store query request 1 and its corresponding query result in memory. Then, if the electronic device receives a new query request, such as query request 2, it can first determine whether query request 2 is the same as a historical query request (e.g., query request 1). If query request 2 is the same as a historical query request, it can be determined that query request 2 hits the cached data in memory, and step 703 can be executed. If query request 2 is different from a historical query request, it can be determined that query request 2 does not hit the cached data in memory, and step 704 can be executed. The historical query request can be a query request for which a corresponding query result is currently stored in memory.

[0094] 703. The electronic device retrieves the corresponding data from memory and returns it to the client.

[0095] If a query request for the first data table hits data cached in memory, the electronic device can retrieve the corresponding query result from memory based on the query request and then return it to the client. For example, if the client has previously sent the same query request, when the electronic device receives the same query request again, it can determine that the query request hits data cached in memory and return the corresponding query result from memory to the client.

[0096] It should be noted that steps 702 and 703 are optional. In some other embodiments of this application, steps 702 and 703 may not be executed. That is, after the electronic device receives a query request for the first data table, it can directly execute step 704.

[0097] 704. Electronic devices use SIMD for Bloom index lookups based on query requests.

[0098] If a query request misses cached data, the electronic device can perform a query based on a pre-created Bloom index. When querying based on a Bloom index, parallel computation of the data can be performed using SIMD-enabled instruction sets (such as AVX instruction sets). This allows for parallel AND operations between multiple bits in the bitmap index corresponding to the query item in the query request and multiple bits in the bitmap index corresponding to each tuple in the data table, as well as parallel equality operations between multiple bits in the AND result and multiple bits in the mask. It should be understood that a bitmap index can include multiple bits arranged sequentially, each bit corresponding to a hash value, and the value of each bit indicating whether the corresponding hash value exists. For example, the hash value corresponding to the 5th bit of the bitmap index can be 4; therefore, if the 5th bit of the bitmap index is 1, it indicates that the hash value 4 exists. Based on this, the bitmap index corresponding to each tuple can indicate the hash value of the queried attribute value in each tuple.

[0099] The electronic device can generate a bitmap index corresponding to the query item based on the hash function corresponding to the query item. For example, for the query items x = x1 and y = y1, two hash values ​​corresponding to x1 can be calculated using hash function 1 and hash function 2, and two hash values ​​corresponding to y1 can be calculated using hash function 3 and hash function 4. Based on the four calculated hash values, the bitmap index corresponding to the query item can be obtained. Then, data can be queried based on the bitmap index corresponding to the query item. It should be understood that the hash function corresponding to the query item is also the hash function corresponding to the attribute values ​​included in the query item.

[0100] For example, please see Figure 8Assuming each tuple corresponds to a bitmap index of length 128, the electronic device can load the bitmap index corresponding to tuple 1 into register 1 and the bitmap index corresponding to the query item into register 2. Furthermore, the bitmap indexes corresponding to tuple 1 and the query item can be aligned in the registers. This alignment can be understood as storing the bitmap indexes of tuple 1 and the query item in the same order in the registers. For example, if the 0th bit of the bitmap index of tuple 1 is stored in the 0th bit of register 1, the 0th bit of the bitmap index of the query item also needs to be stored in the 0th bit of register 2. Afterward, the electronic device can perform batch AND operations based on SIMD, that is, perform AND operations on the corresponding bits in register 1 and register 2 in parallel, and store the result in register 3. Then, the AND result can be used to perform an equality operation with the mask. For example, the corresponding bits in register 3 and register 2 can be used for the equality operation in parallel. At this point, the corresponding bits in register 3 and register 2 are equal, which means that tuple 1 satisfies the query item, that is, it satisfies the query condition, and tuple 1 can be used as one of the query results.

[0101] It's understandable that the bit width of the aforementioned register is equal to the length of the bitmap index, both being 128. However, in practice, the bit width of the register and the length of the bitmap index may not be equal; the register's bit width may be greater than the bitmap index's length, or vice versa. When the register's bit width is greater than the bitmap index's length, the electronic device needs to pad the positions outside the bitmap index with 0s when loading the bitmap index corresponding to tuple 1 into register 1. For example, assuming the bitmap index length is 80, the bitmap index corresponding to tuple 1 can be stored in bits 0-79 of register 1, and the electronic device can pad bits 80-127 of register 1 with 0s. Similarly, when the electronic device loads the bitmap index corresponding to the lookup item into register 2, it also needs to pad with 0s. When the register's bit width is less than the bitmap index's length, the electronic device splits the bitmap index corresponding to tuple 1 and the bitmap index corresponding to the lookup item, and then loads them into the register multiple times for parallel AND operations. For example, assuming the bitmap index length is 160, the bitmap index corresponding to tuple 1 and the bitmap index corresponding to the lookup item can be split into 128 + 32. That is, the electronic device can first load 128 bits from the bitmap indexes of tuple 1 and the lookup item into a register and perform a parallel AND operation. Then, the remaining 32 bits from these two indexes can be loaded into a register and performed a parallel AND operation. During the second parallel AND operation, since only 32 bits are used, it cannot fill the 128-bit register; therefore, it needs to be padded with zeros.

[0102] In one possible implementation, if the register's bit width is much larger than the bitmap index length, the bitmap indices corresponding to multiple tuples can be loaded into the register, and then a parallel AND operation can be performed with the bitmap index corresponding to the lookup item. For example, ... Figure 9 As shown, assuming the register width is 256 bits and the bitmap index length is 128 bits, one register can store the bitmap indices corresponding to two tuples. Therefore, the electronic device can load the bitmap index corresponding to tuple 1 into bits 0-127 of register 1, and load the bitmap index corresponding to tuple 2 into bits 128-255 of register 1. Bits 0-127 and 128-255 of register 2 can both store the bitmap index corresponding to the lookup item. Then, the corresponding bits in register 1 and register 2 can be ANDed in parallel, and the result can be stored in register 3. Next, the corresponding bits in register 3 and register 2 can be performed on an equality operation. Since bits 0-127 of register 3 and register 2 are equal, it can be determined that tuple 1 satisfies the lookup item, and tuple 1 can be used as one of the lookup results. Since bits 128-255 of register 3 and register 2 are unequal, it can be determined that tuple 2 does not satisfy the lookup item. As can be seen, this method can compare multiple tuples with query items with a single command, which can further improve the efficiency of data query.

[0103] It should be noted that since the bitmap index corresponding to the query item needs to be ANDed with the bitmap index corresponding to each tuple in parallel, the bitmap index corresponding to the query item only needs to be loaded once during the process of querying tuples that match the query item. For example, the bitmap index corresponding to the query item can be stored in register 2 mentioned above, while register 1 can be replaced with the bitmap index corresponding to different tuples. This reduces the number of times the query item is loaded and reduces communication overhead.

[0104] The electronic device compares the bitmap index corresponding to the query item with the bitmap index corresponding to each tuple in the first data table to obtain the query result. The electronic device can then return the query result to the client.

[0105] It should be noted that when performing data queries based on the query items in the query request, the bitmap index corresponding to the query item is compared with the bitmap index corresponding to each tuple in the first data table to determine all tuples in the first data table that match the query item. However, in one possible implementation, the query request sent by the client may indicate the number of tuples that need to be returned that match the query item (hereinafter referred to as the first number). This first number may be less than the number of tuples that match the query item in the first data table. Therefore, in this case, when the electronic device finds the first number of tuples that match the query item, the electronic device can stop the query. That is, when the electronic device finds the first number of tuples that match the query item, the electronic device does not need to continue comparing the bitmap index corresponding to the query item with the bitmap indexes corresponding to the remaining unmatched tuples in the first data table. For example, suppose the first data table includes tuples 1-8, and the electronic device indicates in the query request that the number of tuples that need to be returned that match the query item is 2. The electronic device can compare the bitmap index corresponding to the query item with the bitmap indexes corresponding to tuples 1-8 in sequence. During the comparison process, when the electronic device reaches tuple 3, it can determine that tuples 1 and tuple 3 match the query item, while tuple 2 does not match the query item. Since two tuples matching the query item have already been obtained, the electronic device can directly return the query result based on tuples 1 and tuple 3 without continuing to compare the bitmap indexes corresponding to tuples 4-8 with the bitmap indexes corresponding to the query item. This allows for faster result return and reduces the number of bitmap index comparisons, saving processing resources for the electronic device.

[0106] In the above processing flow, when the electronic device performs a data query, it can load the bitmap index corresponding to the query item and the bitmap index corresponding to each tuple in the first data table into a register. Then, it can perform parallel bitwise AND operations on multiple bits based on SIMD, and perform parallel equality comparisons between the AND operation results and the mask. This improves the efficiency of data query, reduces user waiting time, and enhances the user experience.

[0107] Based on the above system architecture, please refer to Figure 10 , Figure 10 This is a flowchart illustrating another data query method disclosed in an embodiment of this application. Figure 10 As shown, this data query method can be applied to electronic devices, and the data query method may include, but is not limited to, the following steps:

[0108] 1001. An electronic device receives a query request for a first data table, the query request including query items, the query items including attribute values ​​to be queried.

[0109] The electronic device may store a first data table, which may include a first tuple, and the first tuple may include one or more tuples. The electronic device may also store a first-bit graph index corresponding to the first tuple. Furthermore, the first data table may include one or more queryable attributes, and correspondingly, the first tuple may include one or more queryable attribute values. The first-bit graph index may include multiple bits arranged sequentially, each bit corresponding to a hash value, and the value of each bit indicating whether the corresponding hash value exists. It should be understood that the first-bit graph index corresponding to the first tuple is calculated based on the hash function corresponding to the queryable attribute value in the first tuple; therefore, the values ​​of the multiple bits of the first-bit graph index can be used to characterize the queryable attribute value of the first tuple.

[0110] Specifically, when a user needs to query data from the first data table in the database, the user can send a query request for the first data table to the electronic device through a client. Correspondingly, the electronic device can receive the query request for the first data table from the client. The query request can include query terms, which can include attribute values ​​to be queried. Furthermore, the query request is used to request tuples that satisfy the query terms; however, it should be understood that the returned query results may include some attribute values ​​from the tuples that satisfy the query terms. For example, in the query request `select*fromtbl_Name where x=x2 and y=y2`, `where x=x2 and y=y2` can be query terms, and `x2` and `y2` can be attribute values ​​to be queried.

[0111] In one possible implementation, the queryable attribute value in the first tuple has a first hash value, which includes hash values ​​calculated by the queryable attribute value using multiple hash functions. For example, the first tuple includes a queryable attribute value x1, which may have two corresponding hash values ​​calculated using hash function 1 and hash function 2.

[0112] 1002. The electronic device generates a second bitmap index corresponding to the query item based on the attribute value to be queried.

[0113] The bit values ​​of the second bitmap index corresponding to the query item can be used to represent the attribute value to be queried in the query item.

[0114] 1003. The electronic device compares the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of the first bitmap index corresponding to the first tuple simultaneously to determine whether the first tuple satisfies the query item.

[0115] In one possible implementation, when the electronic device compares the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of multiple bits at the same position in the first bitmap index corresponding to the first tuple, it can first perform a parallel AND operation on the values ​​of the multiple bits in the first bitmap index corresponding to the first tuple and the values ​​of the multiple bits at the same position in the second bitmap index corresponding to the query item, obtaining the result. Then, the electronic device can determine whether the first tuple satisfies the query item based on the AND operation result. Specifically, during the parallel AND operation, the bitmap index corresponding to the query item and the bitmap index corresponding to the first tuple can be loaded into registers respectively, and then the parallel AND operation can be performed based on SIMD instructions. In this way, the AND operation result can be obtained with a single instruction.

[0116] In one possible implementation, determining whether a first tuple satisfies a query term based on the AND operation result may include: simultaneously performing parallel equality operations on the values ​​of multiple bits at the same position included in the second bitmap index corresponding to the query term and the AND operation result, to obtain an equality operation result. This equality operation result can be used to indicate whether the first tuple satisfies the query term. Specifically, during the parallel equality operation, the bitmap index corresponding to the query term and the AND operation result can be loaded into registers respectively, and then the parallel equality operation can be performed based on SIMD instructions. This allows the equality operation result to be obtained with a single instruction.

[0117] In one possible implementation, when the first tuple includes multiple tuples, comparing the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of the first bitmap index corresponding to the first tuple simultaneously includes: sequentially loading the bitmap indices corresponding to N tuples into the storage unit of the first register of the electronic device; copying the second bitmap index corresponding to the query item N times and sequentially loading it into the storage unit of the second register of the electronic device; performing a parallel AND operation on the data in the first register and the second register to obtain the AND operation result; and determining whether the N tuples satisfy the query item based on the AND operation result. Here, N is an integer greater than 1, and the first register and the second register include multiple storage units, each storage unit storing the value of one bit.

[0118] In one possible implementation, the electronic device can cache historical query requests and the corresponding query results. In this case, upon receiving a query request, the electronic device can first determine if the query request is the same as a historical query request. If the query request is the same as a historical query request, it can directly retrieve the query results corresponding to the historical query request. If the query request is different from a historical query request, it can then simultaneously compare the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of the first bitmap index corresponding to the first tuple.

[0119] In one possible implementation, when the first tuple includes multiple tuples, during the creation of the Bloom index, the electronic device can sequentially load the first attribute values ​​of M tuples from the multiple tuples into the storage unit of the third register, and copy the calculation parameters of the first hash function corresponding to the first attribute values ​​multiple times and load them sequentially into the storage unit of the fourth register. Then, the data in the third and fourth registers can be subjected to a first operation in parallel to obtain the first operation result. The first operation result can include the result of performing the first operation on the first attribute values ​​of the M tuples with the calculation parameters in the first hash function. Here, M is an integer greater than 1, the first attribute value can be a queryable attribute value in the tuple, the first hash function is the hash function corresponding to the first attribute value, the calculation parameters in the first hash function are the calculation parameters included in the first hash function, and the first operation is the operation corresponding to the calculation parameters in the first hash function. For example, the first hash function can be x%p1, where p1 can be the calculation parameter in the first hash function, and % can be the first operation. It should be understood that the third and fourth registers include multiple storage units, each of which can be used to store the value of one bit.

[0120] It should be understood that the aforementioned electronic devices can implement parallel computing during data querying based on SIMD instructions. Therefore, the processor of the electronic devices can support corresponding instruction sets, such as the Multimedia Extension Instruction Set, the Single Instruction Multiple Data Extension Instruction Set, and the Advanced Vector Extension Instruction Set.

[0121] It should be noted that the relevant information (i.e., the same or similar information) and related descriptions in the different embodiments described above can be referenced from each other.

[0122] It should be understood that the above Figure 4 , Figure 7 and Figure 10 The above processing flow is illustrated using an electronic device as the executing entity for the interaction, but this application does not limit the executing entity of the interaction. For example, Figure 4 , Figure 7 and Figure 10 The electronic device in the text can also be a chip, chip system, processor (such as the CPU mentioned above) that supports the implementation of the method, or a logic module or software that can implement all or part of the functions of the electronic device (such as the database mentioned above, the storage engine in the database, etc.).

[0123] Based on the above system architecture, please refer to Figure 11 , Figure 11This is a schematic diagram of the structure of an electronic device disclosed in an embodiment of this application. The electronic device 1100 may include a processor 1101, a communication interface 1102, and a memory 1103. The processor 1101, communication interface 1102, and memory 1103 may be interconnected or interconnected via a bus 1104.

[0124] For example, memory 1103 is used to store computer programs and data of electronic device 1100. Memory 1103 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or compact disc read-only memory (CD-ROM). Communication interface 1102 is used to support electronic device 1100 in communication, such as receiving or sending data.

[0125] For example, processor 1101 may be a central processing unit (CPU), a complex programmable logic device, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. A processor may also be a combination that implements computational functions, such as a combination of one or more microprocessors, a combination of a digital signal processor and a microprocessor, etc.

[0126] Processor 1101 may include multiple registers, with register widths of 64 bits, 128 bits, 256 bits, 512 bits, etc. Furthermore, processor 1101 may support SIMD, such as the AVX instruction set.

[0127] In one embodiment, the electronic device 1100 can be the aforementioned electronic device, and the processor 1101 can be used to read the program stored in the aforementioned memory 1103 and execute the aforementioned program. Figure 4 , Figure 7 or Figure 10 The operations performed by the electronic device or components in the electronic device in the method embodiments shown can be referred to the above-mentioned descriptions, and will not be repeated in detail here.

[0128] It should be noted that, Figure 11 The electronic device 1100 shown is merely one implementation of the embodiments of this application. In actual applications, the electronic device 1100 may include more or fewer components, which is not limited here.

[0129] This application also discloses a computer-readable storage medium storing instructions thereon, which, when executed, perform the methods described in the above method embodiments.

[0130] This application also discloses a computer program product including instructions that, when executed, perform the methods described in the above method embodiments.

[0131] Obviously, the embodiments described above are only some embodiments of this application, and not all embodiments. The term "embodiment" as used herein means that a specific feature, structure, or characteristic described in connection with an embodiment can be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily indicate the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will understand, explicitly and implicitly, that the embodiments described herein can be combined with other embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without inventive effort are within the scope of protection of this application. The terms "first," "second," "third," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish different objects and are not used to describe a specific order. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, it may include a series of steps or units, or optionally, steps or units not listed, or optionally other steps or units inherent to these processes, methods, products, or devices. It is understandable that the equal sign in the above conditional judgment can be either greater than or less than one side. For example, the above conditional judgment of a threshold being greater than, less than, or equal to can also be changed to a conditional judgment of the threshold being greater than or equal to, or less than. This is not limited here.

[0132] It is understood that the accompanying drawings show only the parts relevant to this application and not all of them. It should be understood that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe operations (or steps) as sequential processes, many of these operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but may also have additional steps not included in the drawings. The process can correspond to a method, function, procedure, subroutine, subroutine, etc.

[0133] The terms “component,” “module,” “system,” “unit,” etc., used in this specification are used to refer to computer-related entities, hardware, firmware, combinations of hardware and software, software, or software in execution. For example, a unit can be, but is not limited to, a process running on a processor, a processor, an object, an executable file, a thread of execution, a program, and / or distributed between two or more computers. Furthermore, these units can be executed from various computer-readable media on which various data structures are stored. For example, a unit can communicate via local and / or remote processes based on signals having one or more data packets (e.g., data from a second unit interacting with another unit between a local system, a distributed system, and / or a network; for example, the Internet interacting with other systems via signals).

[0134] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of this application. It should be understood that the above description is only a specific embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made on the basis of the technical solution of this application should be included within the scope of protection of this application.

Claims

1. A data query method, characterized in that, The method is applied to an electronic device that stores a first data table, the first data table including a first tuple, and the electronic device also storing a first bitmap index corresponding to the first tuple. The first tuple includes one or more queryable attribute values, and the first bitmap index includes a plurality of sequentially arranged bits. The values ​​of the plurality of bits of the first bitmap index are used to characterize the queryable attribute values ​​of the first tuple. The first bitmap index is a Bloom index, and the queryable attribute values ​​have a first hash value. The first hash value includes hash values ​​calculated by the queryable attribute values ​​using multiple hash functions. The method includes: Receive a query request for the first data table, the query request includes query items, the query items include attribute values ​​to be queried, and the query request is used to request a query for tuples that satisfy the query items; Based on the attribute value to be queried, a second bitmap index corresponding to the query item is generated; the bit values ​​of the second bitmap index corresponding to the query item are used to represent the attribute value to be queried. The values ​​of multiple bits included in the first bitmap index corresponding to the first tuple are simultaneously ANDed with the values ​​of multiple bits at the same position included in the second bitmap index corresponding to the query item to obtain the operation result. The values ​​of multiple bits at the same position included in the second bitmap index corresponding to the operation result and the query item are simultaneously subjected to parallel equality operation to obtain the equality operation result, which is used to indicate whether the first tuple satisfies the query item.

2. The method according to claim 1, characterized in that, The first tuple includes multiple tuples, and the step of simultaneously comparing the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of the first bitmap index corresponding to the first tuple includes: The bitmap indices corresponding to N tuples from the plurality of tuples are sequentially loaded into the storage unit of the first register of the electronic device, where N is an integer greater than 1; The second bitmap index corresponding to the query item is copied N times and loaded sequentially into the storage unit of the second register of the electronic device. The first register and the second register include multiple storage units, and each storage unit is used to store the value of one bit. Perform a parallel AND operation on the data in the first register and the second register to obtain the AND result; Based on the result of the AND operation, determine whether the N tuples satisfy the query term.

3. The method according to claim 1, characterized in that, The electronic device caches historical query requests and the corresponding query results. The method further includes: If the query request is the same as the historical query request, obtain the query results corresponding to the historical query request; The step of simultaneously comparing the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item with the values ​​of the first bitmap index corresponding to the first tuple includes: If the query request is different from the historical query request, the values ​​of multiple bits at the same position in the second bitmap index corresponding to the query item are compared simultaneously with the values ​​of the first bitmap index corresponding to the first tuple.

4. The method according to claim 1 or 2, characterized in that, The first tuple comprises multiple tuples, and the method further includes: The first attribute values ​​of M tuples from the plurality of tuples are sequentially loaded into the storage unit of the third register. The first attribute value is a queryable attribute value in the tuple, and M is an integer greater than 1. The calculation parameters in the first hash function corresponding to the first attribute value are copied multiple times and loaded sequentially into the storage unit of the fourth register. The first hash function is the hash function corresponding to the first attribute value. The third register and the fourth register include multiple storage units, and each storage unit is used to store the value of one bit. The data in the third register and the fourth register are subjected to a first operation in parallel to obtain a first operation result; the first operation result includes the result of the first attribute value of the M tuples being respectively operated with the calculation parameters in the first hash function.

5. The method according to any one of claims 1-3, characterized in that, The processor of the electronic device supports any of the following instruction sets: Multimedia Extended Instruction Set, Single Instruction Multiple Data Extended Instruction Set, and Advanced Vector Extended Instruction Set.

6. An electronic device, characterized in that, The electronic device includes a processor and a memory, wherein the processor invokes a computer program or computer instructions stored in the memory to implement the method as described in any one of claims 1-5.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program or computer instructions that, when executed, implement the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Query method based on regional bitmap indexes in cloud environment

    CN102722531A

  • Data aggregation method and device, equipment and storage medium

    CN114253992A