Data query method, data query device, electronic device and storage medium
By calling the hash index interface in the InnoDB storage engine, the hash index is used to improve the efficiency of equivalent query, and the problem of low equivalence of equivalent query in the InnoDB storage engine is solved, achieving more efficient query and storage space savings.
Patent Information
- Application Number
- CN202110299688.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-19
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-03-19
AI Technical Summary
The query efficiency of using the InnoDB storage engine for equal value queries is not high.
By obtaining the query request and determining that the query type is an equal value query, the hash index interface is called, and the target storage engine that supports hash index determines the target hash index corresponding to the target keyword, and determines the query result based on the index.
It improves the query efficiency of equivalent queries, reduces the number of IO times, saves storage space, and at least partially overcomes the problem of low equirement efficiency of InnoDB storage engine.
Smart Images

Figure CN113051268B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present disclosure relate to the field of computer technology, finance or other fields, and more specifically, to a data query method, a data query device, an electronic device, a computer-readable storage medium and a computer program product. Background Art
[0002] A database is a warehouse for storing data, which is organized and stored according to a certain data structure. Databases can include relational databases and non-relational databases. Among relational databases, MySQL database has a plug-in storage engine. MySQL database includes multiple types of storage engines, such as InnoDB storage engine, CVS (Concurrent Version System) storage engine, Archive storage engine, Memory storage engine and Myisam storage engine. Among them, InnoDB storage engine supports transaction processing and has multiple features, such as atomicity, consistency, independence and persistence. It is one of the most commonly used, core and important storage engines in MySQL database.
[0003] In the process of implementing the concept of the present disclosure, the inventors found that there are at least the following problems in the related art: the query efficiency of equal value query using InnoDB storage engine is not high. Summary of the invention
[0004] In view of this, embodiments of the present disclosure provide a data query method, a data query device, an electronic device, a computer-readable storage medium, and a computer program product.
[0005] One aspect of an embodiment of the present disclosure provides a data query method, comprising: obtaining a query request, wherein the query request includes a target keyword; determining a query type based on the target keyword; in the case where the query type is determined to be an equal value query, calling a hash index interface, wherein the hash index interface is a storage engine interface for a hash index created in response to a creation request for creating a hash index; calling a target storage engine based on the hash index interface to determine a target hash index corresponding to the target keyword through the target storage engine; and determining a query result for the query request based on the target hash index.
[0006] Another aspect of an embodiment of the present disclosure provides a data query device, including: a first acquisition module, used to acquire a query request, wherein the query request includes a target keyword; a first determination module, used to determine a query type based on the target keyword; a first calling module, used to call a hash index interface when determining that the query type is an equal value query, wherein the hash index interface is a storage engine interface for a hash index created in response to a creation request for creating a hash index; a second calling module, used to call a target storage engine according to the hash index interface to determine a target hash index corresponding to the target keyword through the target storage engine; and a second determination module, used to determine a query result for the query request based on the target hash index.
[0007] Another aspect of an embodiment of the present disclosure provides an electronic device, including: one or more processors; and a memory for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described above.
[0008] Another aspect of an embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method described above when executed.
[0009] Another aspect of an embodiment of the present disclosure provides a computer program product, wherein the computer program product includes computer executable instructions, and the instructions are used to implement the method described above when executed.
[0010] According to an embodiment of the present disclosure, by obtaining a query request including a target keyword, determining the query type according to the target keyword, and in the case where the query type is determined to be an equal value query, calling a hash index interface, the hash index interface is a storage engine interface for hash indexes created in response to a create request for creating a hash index, calling a target storage engine according to the hash index interface, determining a target hash index corresponding to the target keyword through the target storage engine, and determining a query result for the query request according to the target hash index. For equal value queries, since the target keyword is processed by calling a hash index interface for hash indexes created in response to a create request for creating a hash index to call a target storage engine supporting hash indexes, the target index is obtained, and the query result is obtained according to the target index, and the query result can be obtained based on the hash index (i.e., the target index) with only one IO, thereby improving the query efficiency, and thus, at least partially overcoming the problem of low query efficiency when using the InnoDB storage engine for equal value queries, thereby saving storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The above and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0012] Figure 1 An exemplary system architecture to which the data query method according to an embodiment of the present disclosure can be applied is schematically shown;
[0013] Figure 2 A flowchart of a data query method according to an embodiment of the present disclosure is schematically shown;
[0014] Figure 3 A schematic diagram of a process for generating an index to be stored according to an embodiment of the present disclosure is schematically shown;
[0015] Figure 4 A schematic diagram schematically shows a method of obtaining a query result based on a B+ tree index according to an embodiment of the present disclosure;
[0016] Figure 5 A block diagram schematically shows a data query device according to an embodiment of the present disclosure; and
[0017] Figure 6 A block diagram of an electronic device suitable for implementing a data query method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0018] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0019] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0020] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0021] In the case of using expressions such as "at least one of A, B, and C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.). In the case of using expressions such as "at least one of A, B, or C, etc.", it should generally be interpreted in accordance with the meaning of the expression generally understood by those skilled in the art (for example, "a system having at least one of A, B, or C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0022] Figure 1 The exemplary system architecture 100 to which the data query method according to the embodiment of the present disclosure can be applied is schematically shown. It should be noted that: Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present disclosure can be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but it does not mean that the embodiments of the present disclosure cannot be used in other devices, systems, environments or scenarios.
[0023] like Figure 1 As shown, the system architecture 100 according to this embodiment may include clients 101, 102, 103, a network 104 and a server 105. The server 105 may be provided with a MySQL database. The network 104 is used to provide a medium for a communication link between the clients 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.
[0024] Users can use clients 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on clients 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients and / or social platform software, etc. (only as examples).
[0025] The clients 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0026] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for query requests sent by users using the clients 101, 102, and 103. The background management server may analyze the received query requests and process them, and feed back the processing results (for example, determining the query type according to the target keyword, and in the case where the query type is determined to be an equal value query, calling the hash index interface, determining the target storage engine according to the hash index interface, determining the target hash index corresponding to the target keyword through the target storage engine, and determining the query result for the query request according to the target hash index) to the clients 101, 102, and 103.
[0027] The architecture of the MySQL database on the server 105 may include a service layer, a storage engine layer, and a physical file layer. The service layer may include connectors, query cache ( Figure 1 Not shown), SQL (Structured Query Language) interface, analyzer, optimizer and executor.
[0028] According to the embodiments of the present disclosure, the connector can be used to be responsible for connection management, authorization authentication and security services, that is, when the client 101, 102, 103 sends a connection request to the MySQL database, since the MySQL database is set on the server 105, it is necessary to establish a communication connection between the client 101, 102, 103 and the server 105. The connector will take out an idle thread from the thread pool maintained by the server 105 or create a new thread as the current connection thread. The connection thread authenticates the connection and maintains the current connection through a user name and password or SSL (Secure Sockets Layer, Secure Sockets Protocol Certificate), and then the client can perform database operations.
[0029] The SQL interface is a set of interfaces for executing SQL statements. The SQL interface may include a storage engine interface. Different storage engines may have corresponding storage engine interfaces, and different storage engines may be called by calling different storage engine interfaces.
[0030] The analyzer can be used to perform semantic analysis on SQL statements and generate analysis results in the form of a parsing data structure tree, wherein the semantic analysis may include lexical analysis and grammatical analysis. The optimizer can be used to process the analysis results to obtain an execution statement. The executor can be used to determine the storage engine interface to be called according to the execution statement, call the corresponding storage engine through the storage engine interface, and execute the execution statement through the corresponding storage engine.
[0031] The storage engine layer can be used to implement data storage and retrieval. The storage engine is a tool that implements table data storage management, indexing methods, and locking mechanisms at the physical level, and provides support for database operations such as adding, deleting, modifying, and querying. The storage engine layer includes multiple types of storage engines, such as the InnoDB storage engine. The storage engine executes execution statements and obtains corresponding execution results.
[0032] The physical file layer can be used to store metadata files and table data files related to the table, so that the data storage of the MySQL database is built on the physical file and the interaction with the storage engine is completed. When executing the execution statement, the storage engine accesses the physical file layer to obtain the corresponding execution result.
[0033] It should be understood that Figure 1 The number of clients, networks and servers in the embodiment is only for illustration. Any number of clients, networks and servers may be provided as required.
[0034] In order to facilitate the storage engine to obtain the corresponding data more quickly, an index can be used. Among them, an index is a separate and physical storage structure for sorting the values of one or more columns in a database table. It provides a pointer to the data value stored in a specified column of the table and sorts the pointer according to a specified sort order. Indexes can include multiple types, such as B+ tree indexes and hash indexes. Different indexes can be applied to different application scenarios, which may include range queries or equal value queries. In the MySQL database, different storage engines may implement the same index differently, and each storage engine may not support all types of indexes. The working method of the index is different, and not all storage engines support all types of indexes.
[0035] In the process of implementing the concept of the present disclosure, the inventors found that the efficiency of using the transactional storage engine in the MySQL database, such as the InnoDB storage engine, for equivalent queries is not high. This is because the InnoDB storage engine only supports B+ tree indexes, and the implementation method of the B+ tree index is that each query needs to search from the root node to the leaf node step by step, which results in the higher the height of the tree, the more IO times, and correspondingly, the longer the time consumption, so the query efficiency of equivalent queries is not high.
[0036] In order to solve the above problems, it is necessary to reduce the number of IO times. The inventor found that for equivalent queries, the hash index method can be used, which only needs one IO to be implemented, which can greatly improve the query efficiency and save storage space. At the same time, the inventor found that due to the open source characteristics of the MySQL database and the storage engine of the MySQL database is a plug-in storage engine, therefore, if the provided storage engine is difficult to meet business needs, the corresponding functions can be written according to business needs to implement a custom storage engine, that is, a storage engine interface can be created according to business needs, thereby realizing the creation of a storage engine. Based on, the inventor proposed a solution for implementing equivalent queries based on an improved storage engine, wherein the improved storage engine can be understood as a storage engine that supports hash indexing, and the storage engine that supports hash indexing can be called a target storage engine, that is, the improved storage engine can be called a target storage engine. In order to obtain the target storage engine, it is necessary to create a hash index interface for the hash index.
[0037] Specifically, the embodiments of the present disclosure provide a data query method, a data query device, an electronic device, a computer-readable storage medium, and a computer program product. The data query method, the data query device, the electronic device, the computer-readable storage medium, and the computer program product of the embodiments of the present disclosure can be applied to the financial field, and can also be used in any field other than the financial field, and the embodiments of the present disclosure are not limited to this. The method may include obtaining a query request, the query request includes a target keyword, and determining the query type according to the target keyword. When the query type is determined to be an equal value query, calling a hash index interface, the hash index interface is a storage engine interface for a hash index created in response to a creation request for creating a hash index, and calling a target storage engine according to the hash index interface to determine a target hash index corresponding to the target keyword through the target storage engine, and determining a query result for the query request according to the target hash index.
[0038] It should be noted that the data query method provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the data query device provided in the embodiment of the present disclosure can generally be set in the server 105. The data query method provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the client 101, 102, 103 and / or the server 105. Accordingly, the data query device provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the client 101, 102, 103 and / or the server 105.
[0039] Figure 2 The following schematically shows a flow chart of a data query method according to an embodiment of the present disclosure.
[0040] like Figure 2 As shown, the method includes operations S210 to S250.
[0041] In operation S210, a query request is obtained, wherein the query request includes a target keyword.
[0042] According to an embodiment of the present disclosure, the target keyword can determine the basis of the query result. The query request can be triggered by a trigger operation of the operating body. The trigger operation can include clicking or sliding, etc.
[0043] In operation S220, a query type is determined according to the target keyword.
[0044] According to an embodiment of the present disclosure, the query type may include a range query or an equivalent query, and the range query may include a full key value query, a key value range query, or a key value prefix query. The query type may be determined based on the target keyword. For example, if the query keyword includes "key=15", the query type may be determined to be an equivalent query. If the query keyword includes "key∈(1,10)", the query type may be determined to be a range query.
[0045] In operation S230, when it is determined that the query type is an equal value query, a hash index interface is called, wherein the hash index interface is a storage engine interface for a hash index created in response to a creation request for creating a hash index.
[0046] In operation S240, the target storage engine is called according to the hash index interface to determine a target hash index corresponding to the target keyword through the target storage engine.
[0047] In operation S250 , a query result for the query request is determined according to the target hash index.
[0048] According to an embodiment of the present disclosure, if the query type is determined to be an equal value query based on the target keyword, it can be determined that a hash index needs to be used to implement the query, that is, a storage engine that supports hash indexes needs to be used to process the query request, wherein the storage engine that supports hash indexes is referred to as a target storage engine. The target storage engine may be an improved InnoDB storage engine. Since the storage engine can be called through a storage engine interface corresponding to the storage engine, in order to enable the storage engine to support hash indexes, a hash index interface for hash indexes needs to be created.
[0049] According to an embodiment of the present disclosure, before determining the query type according to the target keyword, the data query method may further include obtaining a creation request for creating a hash index, parsing the creation request, and obtaining a parsing result for the creation request. If it is determined that the parsing result includes a preset identifier, the hash index creation hash index interface of the target storage engine may be called. The preset identifier may refer to an identifier used to characterize the hash index.
[0050] According to an embodiment of the present disclosure, when it is determined that the query type is an equal value query, a hash index interface is called to call a target storage engine through the hash index interface, and the target storage engine determines a target hash index corresponding to the target keyword based on the target keyword, and determines a query result for the query request based on the target hash index, that is, determines a query result corresponding to the target keyword. Among them, the target hash index can be obtained by processing the target keyword using a hash algorithm. The hash algorithm can include a message digest algorithm (Message-Digest Algorithm, MDA), a secure hash algorithm (Secure Hash Algorithm, SHA) or a cyclic redundancy check (Cyclic Redundancy Check, CRC) algorithm.
[0051] According to the technical solution of the embodiment of the present disclosure, by obtaining a query request including a target keyword, determining the query type according to the target keyword, and in the case of determining that the query type is an equal value query, calling a hash index interface, the hash index interface is a storage engine interface for hash indexes created in response to a create request for creating a hash index, calling the target storage engine according to the hash index interface, so as to determine the target hash index corresponding to the target keyword through the target storage engine, and determining the query result for the query request according to the target hash index. For equal value queries, since the target keyword is processed by calling the hash index interface for hash indexes created in response to a create request for creating a hash index to call the target storage engine supporting hash indexes, the target index is obtained, and the query result is obtained according to the target index, and the query result can be obtained based on the hash index (i.e., the target index) with one IO, thereby improving the query efficiency, and thus, at least partially overcoming the problem of low query efficiency of equal value queries using the InnoDB storage engine, thereby saving storage space.
[0052] According to an embodiment of the present disclosure, the above data query method may further include the following operations.
[0053] Obtain a creation request. Parse the creation request to obtain a parsing result. If it is determined that the parsing result includes a preset identifier for characterizing the creation of a hash index, create a hash index interface according to the parsing result.
[0054] According to an embodiment of the present disclosure, a parser can be used to perform semantic parsing on a creation request. The semantic parsing can include lexical analysis and grammatical analysis to obtain a parsing result for the creation request. If the parsing result includes a preset identifier, a hash index interface can be created based on the parsing result. The preset identifier can be an identifier that represents the creation of a hash index. Exemplarily, the preset identifier can be "USING HASH". The creation request can be a DDL (Data Definition Language, database model definition language) statement.
[0055] According to an embodiment of the present disclosure, determining a query result for a query request according to a target hash index may include the following operations.
[0056] In the case where it is determined that the target hash index exists in the target hash table, a query key-value pair corresponding to the target hash index is determined, wherein the query key-value pair includes a query keyword and a query value corresponding to the query keyword. In the case where it is determined that the number of query key-value pairs is one, the query key-value pair is used as a query result for the query request. In the case where it is determined that the number of query key-value pairs is multiple, a query keyword consistent with the target keyword is searched from multiple query keywords. In the case where it is determined that a query keyword consistent with the target keyword is queried, the query key-value pair corresponding to the query keyword consistent with the target keyword is used as a query result for the query request.
[0057] According to an embodiment of the present disclosure, the address represented by the index in the hash table stores if the target hash index exists in the target hash table, then the query key-value pair corresponding to the target hash index can be determined from the target hash table, that is, the query key-value pair stored at the address represented by the target hash index is determined, and the query key-value pair can be understood as a record. If the number of query key-value pairs is one, the query key-value pair can be determined to be a query result corresponding to the target keyword. If the number of query key-value pairs is at least two, a query keyword consistent with the target keyword can be queried from at least two query keywords. If a query keyword consistent with the target keyword is queried, the query key-value pair corresponding to the query keyword consistent with the target keyword can be determined as a query result for the query request.
[0058] If the target hash index does not exist in the target hash table, it can be determined that the query result for the query request is a null value. Or, if the target hash index exists in the target hash table, when it is determined that the number of query key-value pairs is at least two, no query keyword consistent with the target keyword is found, and it can be determined that the query result for the query request is a null value.
[0059] According to an embodiment of the present disclosure, when it is determined that the number of query key-value pairs is multiple, searching for a query keyword consistent with a target keyword from multiple query keywords may include the following operations.
[0060] When it is determined that the linked list corresponding to the target hash index includes multiple query key-value pairs, the linked list corresponding to the target hash index is traversed to sequentially obtain the query keywords pointed to by the pointers, and a query keyword consistent with the target keyword is determined based on the sequentially obtained query keywords.
[0061] According to an embodiment of the present disclosure, there may be a hash conflict, which means that there are at least two target keywords corresponding to the same target hash index. In order to resolve the hash conflict, an open address method, a rehashing method, a chain address method, or a method of establishing a common overflow area can be used. Optionally, the chain address method can be used to resolve the hash processing, that is, when there are keywords with the same index, the keywords with the same index are linked together in the form of a single linked list, and the head nodes of each single linked list are stored in the target hash table.
[0062] According to an embodiment of the present disclosure, if it is determined that the linked list corresponding to the target hash index includes at least two query key-value pairs, the linked list corresponding to the target hash index can be traversed to sequentially obtain the query keywords pointed to by the pointer. And according to the order of acquisition, it is determined in sequence whether the query keywords pointed to by the pointer are consistent with the target keywords. If it is determined that the query keywords pointed to by the pointer are consistent with the target keywords, the query key-value pairs corresponding to the query keywords consistent with the target keywords can be determined as the query results for the query request.
[0063] According to the embodiments of the present disclosure, since the method for processing hash conflicts using the chain address method is simple and does not involve accumulation, the average query length is relatively short. In addition, deleting a node in a hash table constructed using the chain address method is easy to implement.
[0064] According to an embodiment of the present disclosure, calling a target storage engine according to a hash index interface to determine a target hash index corresponding to a target keyword through the target storage engine may include the following operations.
[0065] According to the hash index interface, the target storage engine is called to process the target keyword by using the message digest algorithm through the target storage engine to obtain an initial hash index corresponding to the target keyword. The data of the initial hash index located at a preset position is extracted to obtain the hash index to be converted. The hash index to be converted is converted from the first base to the binary base to obtain the target hash index.
[0066] According to an embodiment of the present disclosure, the message digest algorithm may include an MD5 algorithm. The preset bits may be configured according to actual business requirements and are not limited here. For example, the preset bits may be the first 16 bits. The first base and the binary may be configured according to actual business requirements and are not limited here. For example, the first base may be hexadecimal. The binary may be decimal.
[0067] According to an embodiment of the present disclosure, the target storage engine can use the MD5 algorithm to process the target keyword to obtain an initial hash index corresponding to the target keyword, extract the first 16 bits of the initial hash index corresponding to the target keyword to obtain the hash index to be converted, and convert the hash index to be converted from hexadecimal to decimal to obtain the target hash index.
[0068] According to an embodiment of the present disclosure, since the initial hash index is a long string, it takes up more space and also makes the query efficiency of data query low. By adopting a method of extracting the preset bit data of the initial hash index to obtain the target hash index, since the target hash index has fewer bits than the initial hash index, the space occupied is reduced and the query efficiency is improved. In addition, by adopting a method of processing the target keyword using a message digest algorithm to obtain the initial hash index corresponding to the target keyword, the number of occurrences of hash conflicts is reduced. Based on the above, the query efficiency and hash conflicts are balanced.
[0069] According to an embodiment of the present disclosure, the above data query method may further include the following operations.
[0070] A storage request is obtained, wherein the storage request includes a key-value pair to be stored, and the key-value pair to be stored includes a keyword to be stored and a value to be stored corresponding to the keyword to be stored. A hash index to be stored corresponding to the keyword to be stored is determined. The key-value pair to be stored is stored to an address represented by the hash index to be stored corresponding to the keyword to be stored, and a target hash table is obtained.
[0071] According to an embodiment of the present disclosure, a hash algorithm can be used to process a keyword to be stored, obtain an initial hash index corresponding to the keyword to be stored, extract data located at a preset position of the initial hash index corresponding to the keyword to be stored, obtain a hash index to be converted, and convert the hash index to be converted from a first base to a binary base to obtain a hash index to be stored corresponding to the keyword to be stored. The hash algorithm may include a message digest algorithm. The message digest algorithm may include an MD5 algorithm. The preset position may be the first 16 bits.
[0072] According to an embodiment of the present disclosure, after determining the hash index to be stored corresponding to the keyword to be stored, the key-value pair to be stored may be stored at the address represented by the hash index to be stored.
[0073] According to an embodiment of the present disclosure, storing the key-value pairs to be stored at the addresses represented by the hash index to be stored corresponding to the keyword to be stored to obtain the target hash table may include the following operations.
[0074] In the case where it is determined that the address represented by the to-be-stored hash index corresponding to the to-be-stored keyword in the original hash table stores a key-value pair, a linked list corresponding to the to-be-stored hash index is obtained. The key-value pair to be stored is stored at the tail of the linked list corresponding to the to-be-stored hash index to obtain a target hash table. In the case where it is determined that the address represented by the to-be-stored hash index corresponding to the to-be-stored keyword in the original hash table does not store a key-value pair, the key-value pair to be stored is stored at the address represented by the to-be-stored hash index corresponding to the to-be-stored keyword to obtain a target hash table.
[0075] According to an embodiment of the present disclosure, in the process of implementing data storage, a chain address method can be used to handle hash conflicts. If it is determined that the address represented by the hash index to be stored in the original hash table does not store a key-value pair, the key-value pair to be stored can be stored at the address represented by the hash index to be stored. If it is determined that the address represented by the hash index to be stored in the original hash table stores a key-value pair, the linked list corresponding to the hash index to be stored can be obtained, and the linked list corresponding to the hash index to be stored can be traversed, and the key-value pair to be stored can be stored at the tail of the linked list corresponding to the hash index to be stored to obtain the target hash table.
[0076] According to an embodiment of the present disclosure, before obtaining a storage request, the process may further include obtaining a table creation request, parsing the table creation request, obtaining a parsing result for the table creation request, determining whether the parsing result for the table creation request includes a preset identifier for characterizing the creation of a hash table, and if it is determined that the parsing result for the table creation request includes a preset identifier for characterizing the creation of a hash table, then establishing an original hash table. Exemplarily, the preset identifier may be "USING HASH".
[0077] According to an embodiment of the present disclosure, when data storage is implemented using the chain address method, a pointer corresponding to the keyword to be stored is also stored in the target hash table.
[0078] For example, Figure 3 A schematic diagram of a process of generating an index to be stored according to an embodiment of the present disclosure is schematically shown. Figure 3 There are 4 key-value pairs to be stored. Figure 3Only the keywords to be stored in each key-value pair to be stored, namely K1, K2, K3 and K4, are shown. The above four keywords to be stored are processed respectively using the formula h(K)=conv(left(MD5(K), 16), 10) to obtain the corresponding indexes to be stored, namely h(K1), h(K2), h(K3) and h(K4). Among them, MD5(K) represents the use of the MD5 algorithm to process the keyword to be stored K, left(MD5(K), 16) represents the extraction of the first 16 bits of the result obtained by processing the keyword to be stored using the MD5 algorithm, and conv(left(MD5(K), 16), 10) represents the conversion of the first 16 bits of data from hexadecimal to decimal. From Figure 3 It can be seen that h(K2) and h(K4) have the same index to be stored, and both are stored in the linked list corresponding to the index to be stored.
[0079] According to an embodiment of the present disclosure, the above data query method may further include the following operations.
[0080] When it is determined that the query type is a range query, the B+ tree index interface is called. According to the B+ tree index interface, the target storage engine is called to determine the query result for the query request through the target storage engine.
[0081] According to an embodiment of the present disclosure, a B+ tree is a balanced search tree designed for a disk or other direct access auxiliary device. In a B+ tree, all nodes are stored in the same layer of leaf nodes in the order of the size of the key value, and are connected by the pointers of each leaf node. If the query type is determined to be a range query based on the query type, the B+ tree index interface can be called, and the target storage engine is called based on the B+ tree index interface, and the query result for the query request is determined by the target storage engine. Among them, in addition to supporting hash indexes, the target storage engine can also support B+ tree indexes. The query starts from the root node of the index, and the slot of the root node stores a pointer to the child node. The target storage engine queries the lower layer based on the pointer, and determines the appropriate pointer to enter the lower layer child node by comparing the value of the node page with the value to be queried. The above pointer sets the upper and lower limits of the value in the page of the child node. The pointer of the leaf node points to the indexed data. There may be multiple layers of node pages between the root node and the leaf nodes. Since the depth of the tree is directly related to the fan-out of the node, in order to reduce the height of the tree and reduce disk IO, the target storage engine of the embodiment of the present disclosure can allow the fan-out number of the node to be configured according to actual business needs, which is not limited here. For example, a B+ tree with a height of 2 can store 4 records per page, and the fan-out number of the node can be 5.
[0082] For example, Figure 4 A schematic diagram of obtaining a query result based on a B+ tree index according to an embodiment of the present disclosure is schematically shown. Figure 4 Starting from the root node, determine whether the target keyword Key is less than Key1; if so, enter the node whose node value is less than Key1, that is, Va1.1, Va1.2, ..., Va1.m; if not, enter the node whose node value is greater than or equal to Key1 and less than Key2, that is, Va2.1, Va2.2, ..., Va2.m. Repeat the above operation until the operation on the leaf node is completed, and obtain the query result from the leaf node.
[0083] According to another data query method of an embodiment of the present disclosure, the method includes the following operations.
[0084] Obtain a creation request, parse the creation request, obtain a parsing result for the creation request, and determine whether the parsing result for the creation request includes a preset identifier for characterizing the creation of a hash index. If so, call the hash index creation hash index interface of the storage engine, obtain the table creation request, parse the table creation request, obtain the parsing result for the table creation request, and determine whether the parsing result for the table creation request includes a preset identifier for representing the creation of a hash table; if so, establish the original hash table, and perform the if-or-no operation; if not, obtain a storage request, wherein the storage request includes a key-value pair to be stored, the key-value pair to be stored includes a keyword to be stored and a value to be stored corresponding to the keyword to be stored, the key-value pair to be stored includes a keyword to be stored and a value to be stored corresponding to the keyword to be stored, determine the hash index to be stored corresponding to the keyword to be stored, and determine whether the address represented by the hash index to be stored corresponding to the keyword to be stored in the original hash table has a key-value pair stored; if so, obtain a linked list corresponding to the hash index to be stored, store the key-value pair to be stored to the tail of the linked list corresponding to the hash index to be stored, and obtain a target hash table; if not, store the key-value pair to be stored to the address represented by the hash index to be stored corresponding to the keyword to be stored, and obtain a target hash table.
[0085] If it is determined that the parsing result for the table creation request does not include a preset identifier for representing the creation of a hash table, the execution operation is terminated.
[0086] A query request is obtained, wherein the query request includes a target keyword, and the query type is determined according to the target keyword, and whether the query type is an equal value query; if so, a hash index interface is called, and a target storage engine is called according to the hash index interface, so that the target keyword is processed by the target storage engine using a message digest algorithm to obtain an initial hash index corresponding to the target keyword, extract the data located at a preset position of the initial hash index, obtain the hash index to be converted, and convert the hash index to be converted from the first base to the second base to obtain the target hash index. Determine whether the target hash index exists in the target hash table; if so, determine the query key-value pair corresponding to the target hash index, and determine whether the number of the query key-value pairs is one; if so, use the query key-value pair as the query result for the query request; if not, traverse the linked list corresponding to the target hash index, obtain the query keywords pointed to by the pointer in sequence, and determine whether there is a query key-value pair consistent with the target keyword according to the query keywords obtained in sequence; if so, use the query key-value pair corresponding to the query keyword consistent with the target keyword as the query result for the query request. If the target hash index does not exist in the target hash table or there is no query key-value pair consistent with the target keyword, it is determined that the query result for the query request is a null value.
[0087] If the query type is not an equality query, the B+ tree index interface is called to determine the query result for the query request through the target storage engine.
[0088] According to the technical solution of the embodiment of the present disclosure, the target keyword is processed by calling the hash index interface for the hash index created in response to the creation request of the hash index to call the target storage engine supporting the hash index, and the target index is obtained. The query result is obtained based on the target index (i.e., the target index), and the query result can be obtained by one IO, thereby improving the query efficiency and saving storage space. By extracting the preset bit data of the initial hash index to obtain the target hash index, the target hash index reduces the number of bits compared to the initial hash index, thereby reducing the space occupation and improving the query efficiency. In addition, by using the message digest algorithm to process the target keyword and obtain the initial hash index corresponding to the target keyword, the number of occurrences of hash conflicts is reduced. For range queries, the orderliness of the B+ tree index is used to achieve the purpose of fast query, grouping and sorting. In the embodiment of the present disclosure, the target storage engine supports hash index and B+ tree index, fully utilizing the advantages of various indexes, thereby improving the query efficiency of the database in various application scenarios.
[0089] Figure 5 A block diagram of a data query device according to an embodiment of the present disclosure is schematically shown.
[0090] like Figure 5 As shown, the data query device 500 may include a first acquisition module 510 , a first determination module 520 , a first calling module 530 , a second calling module 540 and a second determination module 550 .
[0091] The first acquisition module 510 , the first determination module 520 , the first calling module 530 , the second calling module 540 and the second determination module 550 are in communication connection.
[0092] The first acquisition module 510 is used to acquire a query request, wherein the query request includes a target keyword.
[0093] The first determination module 520 is used to determine the query type according to the target keyword.
[0094] The first calling module 530 is used to call the hash index interface when determining that the query type is an equal value query, wherein the hash index interface is a storage engine interface for the hash index created in response to a creation request for creating the hash index.
[0095] The second calling module 540 is used to call the target storage engine according to the hash index interface, so as to determine the target hash index corresponding to the target keyword through the target storage engine.
[0096] The second determination module 550 determines a query result for the query request according to the target hash index.
[0097] According to the technical solution of the embodiment of the present disclosure, by obtaining a query request including a target keyword, determining the query type according to the target keyword, and in the case of determining that the query type is an equal value query, calling a hash index interface, the hash index interface is a storage engine interface for hash indexes created in response to a create request for creating a hash index, calling the target storage engine according to the hash index interface, so as to determine the target hash index corresponding to the target keyword through the target storage engine, and determining the query result for the query request according to the target hash index. For equal value queries, since the target keyword is processed by calling the hash index interface for hash indexes created in response to a create request for creating a hash index to call the target storage engine supporting hash indexes, the target index is obtained, and the query result is obtained according to the target index, and the query result can be obtained based on the hash index (i.e., the target index) with one IO, thereby improving the query efficiency, and thus, at least partially overcoming the problem of low query efficiency of equal value queries using the InnoDB storage engine, thereby saving storage space.
[0098] According to an embodiment of the present disclosure, the data query device 500 may further include a second acquisition module, a parsing module and a creation module.
[0099] The second acquisition module is used to acquire the creation request.
[0100] The parsing module is used to parse the creation request and obtain the parsing result.
[0101] The creation module is used to create a hash index interface according to the parsing result when it is determined that the parsing result includes a preset identifier for characterizing the creation of the hash index.
[0102] According to an embodiment of the present disclosure, the second determination module 540 may include a first determination submodule, a second determination submodule, a query submodule, and a fourth determination submodule.
[0103] The first determination submodule is used to determine a query key-value pair corresponding to the target hash index when it is determined that the target hash index exists in the target hash table, wherein the query key-value pair includes a query keyword and a query value corresponding to the query keyword.
[0104] The second determining submodule is configured to, when it is determined that the number of the query key-value pairs is one, use the query key-value pairs as the query result for the query request.
[0105] The query submodule is used to search for a query keyword consistent with the target keyword from multiple query keywords when it is determined that the number of query key-value pairs is multiple.
[0106] The third determining submodule is configured to, when it is determined that a query keyword consistent with the target keyword is found in the search, use the query key-value pair corresponding to the query keyword consistent with the target keyword as a query result for the query request.
[0107] According to an embodiment of the present disclosure, the query submodule may include a traversal unit and a determination unit.
[0108] The traversal unit is used to traverse the linked list corresponding to the target hash index and sequentially obtain the query keywords pointed to by the pointer when it is determined that the linked list corresponding to the target hash index includes multiple query key-value pairs.
[0109] The determination unit is used to determine the query keyword consistent with the target keyword according to the query keywords obtained in sequence.
[0110] According to an embodiment of the present disclosure, the second calling module 540 may include a calling submodule, an extracting submodule, and a converting submodule.
[0111] The calling submodule is used to call the hash index interface to process the target keyword using the message digest algorithm through the storage engine to obtain an initial hash index corresponding to the target keyword.
[0112] The extraction submodule is used to extract the data whose initial hash index is located at a preset position to obtain the hash index to be converted.
[0113] The conversion submodule is used to convert the hash index to be converted from the first base to the binary base to obtain the target hash index.
[0114] According to an embodiment of the present disclosure, the data query device 500 may further include a third acquisition module, a third determination module and a storage module.
[0115] The third acquisition module is used to acquire a storage request, wherein the storage request includes a key-value pair to be stored, and the key-value pair to be stored includes a keyword to be stored and a value to be stored corresponding to the keyword to be stored.
[0116] The third determining module is used to determine the hash index to be stored corresponding to the keyword to be stored.
[0117] The storage module is used to store the key-value pair to be stored at the address represented by the hash index to be stored corresponding to the keyword to be stored, so as to obtain a target hash table.
[0118] According to an embodiment of the present disclosure, the storage module may include an acquisition submodule, a first storage submodule and a second storage submodule.
[0119] The acquisition submodule is used to acquire a linked list corresponding to the hash index to be stored when it is determined that a key-value pair is stored at an address represented by the hash index to be stored corresponding to the keyword to be stored in the original hash table.
[0120] The first storage submodule is used to store the key-value pairs to be stored at the end of the linked list corresponding to the hash index to be stored, so as to obtain a target hash table.
[0121] The second storage submodule is used to store the key-value pair to be stored at the address represented by the hash index to be stored corresponding to the keyword to be stored, when it is determined that the address represented by the hash index to be stored corresponding to the keyword to be stored in the original hash table does not store the key-value pair, so as to obtain the target hash table.
[0122] According to an embodiment of the present disclosure, the data query device 500 may further include a third calling module and a fourth calling module.
[0123] The third calling module is used to call the B+ tree index interface when it is determined that the query type is a range query.
[0124] The fourth calling module is used to call the target storage engine according to the B+ tree index interface to determine the query result for the query request through the target storage engine.
[0125] According to the modules, submodules, and units of the embodiments of the present disclosure, any multiple or at least part of the functions of any multiple thereof can be implemented in one module. According to the modules, submodules, and units of the embodiments of the present disclosure, any one or more thereof can be split into multiple modules for implementation. According to the modules, submodules, and units of the embodiments of the present disclosure, any one or more thereof can be at least partially implemented as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a System on a Chip, a System on a Substrate, a System on a Package, an Application Specific Integrated Circuit (ASIC), or can be implemented by hardware or firmware of any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation modes of software, hardware, and firmware or in any appropriate combination of any of them. Alternatively, according to the modules, submodules, and units of the embodiments of the present disclosure, one or more thereof can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding function can be executed.
[0126] For example, any of the first acquisition module 510, the first determination module 520, the first call module 530, the second call module 540, and the second determination module 550 can be combined in one module / submodule / unit for implementation, or any of the modules / submodules / units can be split into multiple modules / submodules / units. Alternatively, at least part of the functions of one or more modules / submodules / units in these modules / submodules / units can be combined with at least part of the functions of other modules / submodules / units and implemented in one module / submodule / unit. According to an embodiment of the present disclosure, at least one of the first acquisition module 510, the first determination module 520, the first call module 530, the second call module 540, and the second determination module 550 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or by any one of the three implementation methods of software, hardware, and firmware, or by a suitable combination of any of them. Alternatively, at least one of the first acquisition module 510, the first determination module 520, the first calling module 530, the second calling module 540 and the second determination module 550 may be at least partially implemented as a computer program module, which may perform corresponding functions when executed.
[0127] It should be noted that the data query device part in the embodiment of the present disclosure corresponds to the data query method part in the embodiment of the present disclosure. The description of the data query device part specifically refers to the data query method part, which will not be repeated here.
[0128] Figure 6 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present disclosure is schematically shown. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0129] like Figure 6As shown, the electronic device 600 according to the embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 602 or the program loaded from the storage part 608 to the random access memory (RAM) 603. The processor 601 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include an onboard memory for caching purposes. The processor 601 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present disclosure.
[0130] In RAM 603, various programs and data required for the operation of electronic device 600 are stored. Processor 601, ROM 602 and RAM 603 are connected to each other via bus 604. Processor 601 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 602 and / or RAM 603. It should be noted that the program can also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0131] According to an embodiment of the present disclosure, the electronic device 600 may further include an input / output (I / O) interface 605, which is also connected to the bus 604. The electronic device 600 may further include one or more of the following components connected to the I / O interface 605: an input portion 606 including a keyboard, a mouse, etc.; an output portion 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 608 including a hard disk, etc.; and a communication portion 609 including a network interface card such as a LAN card, a modem, etc. The communication portion 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage portion 608 as needed.
[0132] According to an embodiment of the present disclosure, the method flow according to an embodiment of the present disclosure can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program contains a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, the above-mentioned functions defined in the system of the embodiment of the present disclosure are executed. According to an embodiment of the present disclosure, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.
[0133] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0134] According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include, but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device.
[0135] For example, according to an embodiment of the present disclosure, the computer-readable storage medium may include the ROM 602 and / or the RAM 603 described above and / or one or more memories other than the ROM 602 and the RAM 603 .
[0136] The embodiments of the present disclosure also include a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiments of the present disclosure. When the computer program product runs on an electronic device, the program code is used to enable the electronic device to implement the data query method provided by the embodiments of the present disclosure.
[0137] When the computer program is executed by the processor 601, the above functions defined in the system / device of the embodiment of the present disclosure are executed. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0138] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 609, and / or installed from a removable medium 611. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0139] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).
[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram may represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box may also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions. It can be understood by those skilled in the art that the features recorded in the various embodiments and / or claims of the present disclosure can be combined and / or combined in a variety of ways, even if such a combination or combination is not explicitly recorded in the present disclosure. In particular, without departing from the spirit and teaching of the present disclosure, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0141] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A data query method, comprising: Obtaining a query request, wherein the query request includes a target keyword; Determine a query type according to the target keyword, the query type being an equal value query or a range query; Get the creation request; Parsing the creation request to obtain a parsing result; In the case where it is determined that the parsing result includes a preset identifier for characterizing the creation of a hash index, creating a hash index interface according to the parsing result; In the case where it is determined that the query type is an equal value query, calling a hash index interface; According to the hash index interface, calling the target storage engine to determine the target hash index corresponding to the target keyword through the target storage engine; Determine a query result for the query request according to the target hash index; When it is determined that the query type is a range query, calling a B+ tree index interface; According to the B+ tree index interface, the target storage engine is called to determine the query result for the query request through the target storage engine, wherein the target storage engine supports hash index and B+ tree index.
2. The method according to claim 1, wherein: The determining, according to the target hash index, a query result for the query request includes: In the case of determining that the target hash index exists in the target hash table, determining a query key-value pair corresponding to the target hash index, wherein the query key-value pair includes a query keyword and a query value corresponding to the query keyword; In a case where it is determined that the number of the query key-value pairs is one, using the query key-value pairs as a query result for the query request; When it is determined that the number of the query key-value pairs is multiple, searching for a query keyword consistent with the target keyword from the multiple query keywords; and In the case where it is determined that a query keyword consistent with the target keyword is found, the query key-value pair corresponding to the query keyword consistent with the target keyword is used as a query result for the query request.
3. The method according to claim 2, wherein: When it is determined that the number of the query key-value pairs is multiple, searching for a query keyword consistent with the target keyword from multiple query keywords includes: In the case where it is determined that the linked list corresponding to the target hash index includes a plurality of the query key-value pairs, traversing the linked list corresponding to the target hash index to sequentially obtain the query keywords pointed to by the pointers; and According to the query keywords acquired in sequence, a query keyword consistent with the target keyword is determined.
4. The method according to claim 1, wherein: The calling of the target storage engine according to the hash index interface to determine the target hash index corresponding to the target keyword through the target storage engine includes: According to the hash index interface, calling the target storage engine, so as to process the target keyword by the target storage engine using a message digest algorithm to obtain an initial hash index corresponding to the target keyword; Extracting data located at a preset position of the initial hash index to obtain a hash index to be converted; and The to-be-converted hash index is converted from a first base to a binary base to obtain the target hash index.
5. The method according to claim 2, further comprising: Obtaining a storage request, wherein the storage request includes a key-value pair to be stored, and the key-value pair to be stored includes a keyword to be stored and a value to be stored corresponding to the keyword to be stored; Determine a hash index to be stored corresponding to the keyword to be stored; and The key-value pair to be stored is stored at an address represented by a hash index to be stored corresponding to the keyword to be stored, to obtain the target hash table.
6. The method according to claim 5, wherein: The step of storing the key-value pair to be stored at an address represented by a hash index to be stored corresponding to the keyword to be stored, to obtain the target hash table, includes: In the case where it is determined that a key-value pair is stored at an address represented by a to-be-stored hash index corresponding to the to-be-stored keyword in the original hash table, obtaining a linked list corresponding to the to-be-stored hash index; Storing the key-value pairs to be stored at the end of the linked list corresponding to the hash index to be stored, to obtain the target hash table; and When it is determined that the key-value pair is not stored at the address represented by the hash index to be stored corresponding to the keyword to be stored in the original hash table, the key-value pair to be stored is stored at the address represented by the hash index to be stored corresponding to the keyword to be stored to obtain the target hash table.
7. A data query device, comprising: A first acquisition module is used to acquire a query request, wherein the query request includes a target keyword; A first determination module is used to determine a query type according to the target keyword, wherein the query type is an equal value query or a range query; The second acquisition module is used to obtain the creation request; The parsing module is used to parse the creation request and obtain the parsing result; A creation module, used for creating a hash index interface according to the parsing result when it is determined that the parsing result includes a preset identifier for characterizing the creation of the hash index; A first calling module, configured to call a hash index interface when determining that the query type is an equal value query; A second calling module is used to call a target storage engine according to a hash index interface, so as to determine a target hash index corresponding to the target keyword through the target storage engine; A second determination module determines a query result for the query request according to the target hash index; A third calling module is used to call a B+ tree index interface when determining that the query type is a range query; The fourth calling module is used to call the target storage engine according to the B+ tree index interface to determine the query result for the query request through the target storage engine, wherein the target storage engine supports hash index and B+ tree index.
8. An electronic device comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, wherein the computer program is used to implement the method according to any one of claims 1 to 6 when executed by a processor.
Citation Information
Patent Citations
User-defined metadata-oriented indexing and querying method and system
CN111427847A